Saving Excel Workbooks with VBA
Open a Workbook
To open a workbook file, use the Open method. For example, the following code opens the workbook named "Book1.xlsx":
Dim wb As Workbook Set wb = Workbooks.Open("C:\path\to\Book1.xlsx")
Save a Workbook
To save a workbook, use the Save method. For example, the following code saves the active workbook:
ActiveWorkbook.Save
Save a Workbook in its Current Location With Its Current Name
To save a workbook in its current location with its current name, use the following code:
ActiveWorkbook.Saved = True
Save a Workbook in a New Location With a New Name
To save a workbook in a new location with a new name, use the following code:
ActiveWorkbook.SaveAs Filename:="C:\path\to\new_workbook.xlsx"
Komentar