Save Method of Workbook Object VBA

We can save workbook by using ‘Save’ method of workbook object in Excel VBA. Please find the following brief description about save method of workbook object.



50+ Project Management Templates Pack
Excel PowerPoint Word

Advanced Project Plan & Portfolio Template
Excel Template

Business Presentations Templates Pack
PowerPoint Slides

20+ Excel Project Management Pack
Excel Templates

20+ PowerPoint Project Management Pack
PowerPoint Templates

10+ MS Word Project Management Pack
Word Templates

Why we need to Save Workbook using VBA?

When we do any changes in Excel workbook then we may want to save the changes for further reference. So that only we need to save workbook to see modifications when you open your workbook next time. It Saves changes to the specified workbook.

VBA Save Workbook – Syntax

Here is the syntax to save workbook using VBA.

Workbooks(“Your Workbook Name”).Save()

In the above syntax we are using ‘Save’ method of workbook object to save the workbook.

VBA Save Workbook:Example 1

Please find the below example, It will show you how to save workbook.

Sub Save_Workbook()
Dim Wkb As Workbook
Set Wkb = Workbooks.Add
End Sub

Explanation: In the above example we have created variable named Wkb in the first statement. We have used ‘Add’ method of workbook object to add new workbook and then assigned it to object named Wkb in the second statement. At last in the third statement we have used ‘Save’ method of workbook object to save newly created workbook.

VBA Save Workbook: Example 2

Please find the below example, It will show you how to save active workbook.

Sub Save_Active_Workbook()
End Sub

Note: Here ActiveWorkbook object represents the workbook which we currently activated.

VBA Save Workbook – Instructions

Please follow the below steps to execute the VBA code to save the excel file.
Step 1: Open any existing Excel workbook
Step 2: Press Alt+F11 – This will open the VBA Editor
Step 3: Insert a code module from then insert menu
Step 4: Copy the above code and paste in the code module which have inserted in the above step
Step 5: Activate any workbook
Step 6: Now press F5 to execute the code
Now you can observe that your Active Excel workbook is saved with the changes.


Leave A Comment

Related pages

protect excel passwordvba msgbox ok cancelvlookup lock table arrayfso.deletefileexcel vba close userformunprotect workbook structuremacro to close workbookexcel combining worksheetshelpful excel macrossurface plots in excelexcel range vb netfollow hyperlink vba excelcolour formula in excel 2007vba selection endexcel 2010 unhide rowsexcel macro to open files in a folderhow to write vba code in excelexcel offset formulaworkbooks.activatemacro examples in excelexcel project tracker templatespss sqlvbscript example programsvba row countvb nested ifhow to highlight duplicates in excel 2003vba operatorvlookup using vbahow to consolidate excel fileshide columns excelcopy a worksheet to another workbookremove all hyperlinks excel 2007estimate template word freeexcel substitute examplemicrosoft excel timetable templateunprotect excel workbook 2010 without passwordexcel isnumber functionvlookup right to leftcommand button in excel 2007check if workbook is open vbaexcel 2007 calendar templatehow to change excel columns to rowsproject dashboard templateshow to unmerge cells in wordexcel 2007 autosaveexcel function in vbaspecialcells vbahow to collapse columns in excelhow to insert a title on excelexcel find duplicate records3d column chart excelsheets vbaexcel syntaxlearn macros in excelexcel vba applicationsvba variabledashboard reporting templatesusing vlookup in vbahow to create worksheet in excelhow to delete hyperlink in excelhow to sort numbers in ascending order in excelhow to merge data from multiple worksheets in exceldelete blank rows in excelhow to remove columns in excelexcel 2007 stacked bar chartdcl queriesvba filedialog filterhow to do vlookup in excel 2010 step by stepexplain macros in excelhow do you hyperlink in excelcell color excel vbamicrosoft excel 2010 test questions and answers