SaveAs Method of Workbook Object VBA

We can save workbook by using ‘SaveAs’ method of workbook object in Excel VBA. Please find the following brief description about saveas 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 SaveAS a Workbook using VBA?

When we do any changes in the existing workbook, later we may wanted to see the file without changes. So that we can saves changes to the workbook in a different file using ‘SaveAs’ method of workbook object.

VBA SaveAS Workbook – Syntax

Here is the syntax to SaveAs workbook using VBA.

Workbooks(“Your Workbook Name”).SaveAs(

[Filename], [FileFormat], [Password], [WriteResPassword], [ReadOnlyRecommended], [CreateBackup], [AccessMode As XlSaveAsAccessMode = xlNoChange], [ConflictResolution], [AddToMru], [TextCodepage], [TextVisualLayout], [Local])

In the above syntax we are using ‘SaveAs’ method of workbook object to save the workbook in another location with modification(s).

VBA SaveAS Workbook:Example 1

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

Sub SaveAs_Workbook()
Dim Wkb As Workbook
Set Wkb = Workbooks.Add
ActiveWorkbook.SaveAs Filename:="C:\Sample.xlsm" 
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 ‘SaveAs’ method of workbook object to save workbook in another location and the file name is “C:\Sample.xlsm” (You can change the file name according to your wish).

VBA SaveAS Workbook – Instructions

Please follow the below step by step instructions to execute the above mentioned VBA macros or codes:

  1. Open an Excel Workbook
  2. Press Alt+F11 to Open VBA Editor
  3. Insert a Module from Insert Menu
  4. Copy the above code for activating a range and Paste in the code window(VBA Editor)
  5. Save the file as macro enabled workbook
  6. Press ‘F5’ to run it or Keep Pressing ‘F8’ to debug the code line by line.

One Comment

  1. Tommaso August 18, 2016 at 6:35 PM - Reply


    I am trying to combine the :
    strFileToOpen = Application.GetOpenFilename
    Workbooks.Open Filename:=strFileToOpen

    with a SaveAs function. I need it becuase I am trying to create a Macro where I need to open a file that is not always named in the same way, have the macro save it with a standard name, for example: Test Sample, and have the macro work on it. The Macro should take the infomartion needed from this file and report it on the main file where the Macro is running. Finally the Macro should delete the “Test Sample” file and save the file where the Macro is running with a new name.

    I hope this makes sense enough for you to understand what I am struggling with!


Leave A Comment

Related pages

dml languagemessage boxes in vbexcel vba cell widthsql ddl dml dcl tcl commands with examplesaccess vba case statementhow to insert cells in exceladvanced excel spreadsheet templateshow to remove all blank rows in exceladodb.connection providervba tutorial accessactiveworkbook saveassql query practice questions answers pdfawesome excel trickshyperlink on excelhyperlink shortcut keyvlookup using two criteriaexcel find duplicate values in columnsimple if statement excelconsolidate data from multiple worksheets in a single worksheethow to create bar chart in excel 2007case statement in excel formulaactivecell rangeexcel if statement stringpassword worksheetexcel unhide all cellsvlookup formula in excel 2003interview questions for programmers and answershow to make pivot chart in excel 2010macro to save excel filewhat is hlookup in excelunhiding column aconsolidate excel worksheetsexcel vba last cellmerge cell in excelvba oledb connection stringwindows.activate vbaexcel formula chartdynamic chart excelmicrosoft planner templatesvba select foldervbscript tutorial for excelexcel vba connect to sql serverddl dml dcl in sql serverhyperlink to excel worksheetms excel 2007 formulas with exampleseasy vlookup tutorialdeclaring variables in vbavba scriptsexcel userform templateshow to colour duplicates in excelhow to remove cells in excelgantt chart template for wordexcel match function examplevba excel examples pdfvba macro examplespowerpivot excel 2010 tutorialexcel offset examplestask management excel template freedata dashboard templatevlookup 2 conditionsvba combobox add itemyes no msgbox vbavba sql query excelrca template wordproject status dashboard pptmacro programing in excelrefresh worksheet vbavba code samplessales dashboard examplescountif on excelexcel vba matrixhow to create data entry form in excel 2007how to create macros in excel 2007vlookup excel 2010 examplewhat is the shortcut key to hide row in excelmicrosoft excel test for interviewhow to write if statements in exceluseful vbaunderstanding macros in excelms access 2007 vba programming tutorial pdfmatch excel formulahow to adjust cell width in excel