Workbook.SaveAs

Use this function to save the workbook to a file.

Syntax Parameters Return value
Function Workbook.SaveAs( _
    Name As String, _
    Optional Overwrite As Variant = 0) As Boolean
  • Name [in]

    The fully-qualified pathway to where the workbook shall be saved.

    Type: String

  • Overwrite [in, optional]

    Whether or not to overwrite the file if it already exists. This parameter defaults to False.

    Type: Variant

    Default value: 0

Boolean

SVB Example

Backing up a workbook document

Option Base 1
Option Explicit
Sub Main
    Dim wb As Workbook
    Set wb = ActiveWorkbook
    Dim FilePath As String
    FilePath = wb.FullName
    'save a backup copy of the workbook in the
    'same directory
    wb.SaveAs(FilePath & ".bak")
End Sub