[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.
Dim Wkb As Workbook
Set Wkb = Workbooks.Add
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:
- Open an Excel Workbook
- Press Alt+F11 to Open VBA Editor
- Insert a Module from Insert Menu
- Copy the above code for activating a range and Paste in the code window(VBA Editor)
- Save the file as macro enabled workbook
- Press ‘F5’ to run it or Keep Pressing ‘F8’ to debug the code line by line.