VBA SaveAs Workbook in Excel

VBA SaveAs Workbook is to Save changes to the workbook. And save workbook as a different Workbook file using SaveAs method of Workbook object. Workbook is a part of workbooks collection.

Syntax for SaveAs Workbook Method

Here is the following syntax to SaveAs Workbook.

expression.SaveAs([FileName], [FileFormat], [Password], [WriteResPassword], _
    [ReadOnlyRecommended], [CreateBackup], [AccessMode As XlSaveAsAccessMode = xlNoChange], _
    [ConflictResolution], [AddToMru], [TextCodepage], [TextVisualLayout], [Local])

Where expression is a required parameter. It represents Workbook object which is part of workbooks collection.
All other parameters are optional parameters.

Macro to Save Workbook as Different Workbook in Excel VBA

Let us see the following example. It Saves workbook as a different Workbook file.

'VBA SaveAs Workbook in Excel
Sub VBA_SaveAs_Workbook()

    'Variable declaration
    Dim oWorkbook As Object
    
    'Create new workbook
    Set oWorkbook = Workbooks.Add
    
    'Save Workbook as different Workbook file
    ActiveWorkbook.SaveAs Filename:="D:\VBAF1\New_File.xlsx"

End Sub

Instructions to use Macro

Here are the instructions to use above macro procedure in Visual basic editor.

  • SaveAs Visual Basic Editor(VBE) by clicking Alt +F11
  • Go to code window by clicking F7
  • Copy above specified macro or procedure
  • Paste above copied code in code window
  • Run macro by clicking F5 or Run command
  • You can see output on the screen
  • Find above output screenshot of the specified procedure.

Related Workbook Object articles

You may also like the related Workbook Object articles.

VBA Workbook Object




Leave a Comment

Your email address will not be published. Required fields are marked *