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.

PREMIUM TEMPLATES LIMITED TIME OFFER

ON SALE80% OFF

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
Wkb.Save
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()
ActiveWorkbook.Save
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.

LIMITED TIME OFFER

Leave A Comment


Related pages


vba workbookinsert column in excel shortcutado connectionstringvba statusbarsample project timelineshow to delete empty cellsexcel macro tutorial pdfadodb.recordset examplepowerpoint dashboard examplesvba dropdownlookup excel 2007insert a column in excelvlook up examplesis there a way to delete duplicates in excelexcel blank cell ifdelete blanks in excelprovider msdasqlplanning schedule template excellistbox excelcost estimation software free downloadvba code for yes no message boxbreak excel vbaword templates agendaaverageifs exampleunprotect an excel worksheetexcel macro remove duplicateshow to hyperlink in excelexcel tutorial beginnerssql query for sorting data in ascending ordersql query interview questions and answers for freshers pdfhow to use pivot table in excel 2010 with examplehow to do data validation in excel 2007how do i get rid of duplicates in excelexcel modaliferror formulaexcel conditional rangecheckbox syntaxvba macro codehow to use sumif functionswot analysis word templatehow to unhide cells in excelvba new linevlookup example in hindihlookup in excel with examplevba user inputsql interview question answer pdfcombine excel worksheets into oneexcel advanced filter date rangevba delete recordexcel filter table based on cell valueopen a workbook in excel vbaredim vbavba excel gotoexcel vba adodb connection string sql serveractive x checkvba excel pastevba workbookunlock password protected excel sheetquery sql from excelopen excel file using vbahow can i unprotect an excel sheethow to delete extra rows in excelwhat are vlookups in excelautofit in excel 2007vba excel moduledisplay message box vbapivot table formulas excel 2010excel offset vlookupexcel password cracker macroexcel macro sheetshide columns vbaexample vlookup formulaexcel vba sample codewhat is the use of vlookup function in excelvba securitymath and trig functions in excel