How to Save a Workbook Without a Prompt with Excel VBA (Easy Steps)

Dataset Overview

We’ve included a sample data set in the image below to demonstrate the difference after running the VBA codes to stop the prompting. While saving the file, we’ll use VBA codes to disable the display alert message.

Sample Data


Step 1 – Create a Module to Enter VBA Code

  • Press Alt + F11 to open the VBA Macro.
  • Click on the Insert tab.
  • Select Module to create a new module.

Easy Steps to Save a Workbook without Prompt with Excel VBA

Read More: Create New Workbook and Save Using VBA in Excel


Step 2 – Insert SaveAs Function in Code

  • To use the SaveAs function in this workbook, enter (), and select SaveAs from the list of available functions.

Easy Steps to Save a Workbook without Prompt with Excel VBA

Read More: How to Save a Copy as XLSX Using Excel VBA


Step 3 – Add File Address and Name in VBA Code

  • Go to the file location and copy the address.

Easy Steps to Save a Workbook without Prompt with Excel VBA

  • Paste the address under the Filename argument of the SaveAs function.
  • Enter the file name.
  • Close the address and the file name with inverted commas (” “).

Easy Steps to Save a Workbook without Prompt with Excel VBA

  • After adding the address, enter a comma and enter 52 for the FileFormat argument.

Easy Steps to Save a Workbook without Prompt with Excel VBA

  • That is how the final codes will appear.
Sub Without_Prompt()
ThisWorkbook.SaveAs "C:\Users\Admin\Desktop\Bhubon\Exceldemy\3875_420093_Bhubon_excel vba save workbook without prompt\Save Without Prompt", 52
End Sub

Easy Steps to Save a Workbook without Prompt with Excel VBA

Read More: Excel VBA Save as File Format


Step 4 – Run VBA Code and Check for Error

  • A prompt message will pop up because we didn’t disable the Alerts message.
  • Click No.

Easy Steps to Save a Workbook without Prompt with Excel VBA

  • Finally, click on End.

Easy Steps to Save a Workbook without Prompt with Excel VBA


Step 5 – Enter a Code to Disable the Prompt Message

  • To disable the prompt message, we need to disable the DisplayAlerts message.
  • Set the DisplayAlerts option to False to prevent prompting.
  • Enter the following codes in the Module:
Sub Without_Prompt()
'Command to not to show the Prompt
Application.DisplayAlerts = False
'Apply command to save the file
'In the File Name argument give the file name and address
ThisWorkbook.SaveAs "C:\Users\Admin\Desktop\Bhubon\Exceldemy\3875_420093_Bhubon_excel vba save workbook without prompt\Save Without Prompt", 52
Application.DisplayAlerts = True
End Sub

Easy Steps to Save a Workbook without Prompt with Excel VBA


Step 6 – Run VBA Code After Disabling DisplayAlerts Command

  • Click the Run button or press F5 to execute the VBA codes.
  • No alerting message will be prompted now.

Sample Data


Step 7 – Check Final Result

  • In your sample data set, change the recipient’s name from Brine to Bhubon.

Sample Data

  • Press F5 to run the program, and no message will pop up.
  • Close the worksheet without saving it.

Sample Data

  • Open the file and verify that it has been saved with the latest changes you made.

Sample Data


Download Practice Workbook

You can download the practice workbook from here:


Related Articles

Get FREE Advanced Excel Exercises with Solutions!
Bhubon Costa
Bhubon Costa

Bhubon Costa, B.Sc. in Naval Architecture & Marine Engineering from Bangladesh University of Engineering & Technology, has worked with the ExcelDemy since 2021. Currently, he has been working as a reviewer. Notably, he has written over 90 articles and led several VBA content development teams. He has a great passion for the fields of data analytics and data science. His areas of expertise include Excel VBA, Power Query, Pivot Table, Power BI, MySQL, PostgreSQL, machine learning, and Python... Read Full Bio

2 Comments
  1. if the new file is opened with the same name, it will be prompted

    • Reply MD. JUNAED-AR-RAHMAN
      Junaed-Ar-Rahman Mar 9, 2023 at 1:00 PM

      Dear HARIRI,

      When you use the following command in your code, the prompt will not appear.
      Application.DisplayAlerts = False
      However, if you want to open a new file in the same name in the same folder, there may be two scenarios. You might be able to do that without any obstacles because you have a file with .xlsm extension only with that name and no .xlsx file with that name. But if you have two files with same name in same folder, one with .xlsm extension and another with .xlsx extension, then you cannot open a new Excel file in that folder. Prompt will appear to warn you that there is a folder with the same name and you will have to discard that action or have to modify the file name.

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo