How to Save an Excel Workbook to Another Drive with VBA
Question details
The user needs to automate saving an active Excel workbook to a specific drive or directory using VBA.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Automating file management by saving an Excel file to a designated folder path using a VBA macro.
- Observed behavior
- Using the VBA SaveAs method requires correct syntax, a valid folder path, and an appropriate file format extension to properly execute.
Ensure that the destination folder on the target drive already exists before running the macro, as the standard SaveAs method will not create new directories automatically.
Use the Workbook.SaveAs Method with a Complete File Path
The most direct way to save an active workbook to another drive is by specifying the full path string in the VBA SaveAs method.
When saving an Excel workbook to a different drive, you must construct a complete file path that includes the drive letter, folder hierarchy, the new file name, and the appropriate file extension.
Press Alt + F11 to open the Visual Basic for Applications (VBA) editor in Excel.
Click on 'Insert' in the top menu and select 'Module' to create a new script area.
Enter your VBA code using the syntax: ActiveWorkbook.SaveAs "C:\VBA Folder\" & NewFileName & ".xlsx", xlWorkbookDefault. Make sure to define your NewFileName variable as a valid Windows string.
Press F5 or click the Run button to execute the script and verify that the workbook has been saved to the target drive.

Run VBA Macros Seamlessly in WPS Spreadsheet
WPS Office offers robust support for VBA macros, allowing you to run your existing Excel VBA scripts, including SaveAs file management commands, without modifying the underlying code.
- 1. Enable Developer Tools: Open WPS Spreadsheet, go to the Options menu, and ensure the Developer tab is enabled to access the VBA environment.
- 2. Open the VBA Editor: Navigate to the Developer tab on the ribbon and click 'Visual Basic', or simply press Alt + F11.
- 3. Execute Your SaveAs Macro: Paste your ActiveWorkbook.SaveAs macro into a standard module and click Run to automatically save the file to your desired drive.

Frequently Asked Questions
Why do I get a 'path cannot be found' error when running my macro?
This error generally occurs because the destination folder specified in your path string does not exist on the target drive. The VBA SaveAs method cannot automatically create missing folders, so ensure the path directory is fully created before running the macro.
How do I save a workbook as a macro-enabled file (.xlsm) to another drive?
To save the file as a macro-enabled workbook, change the file extension string in your SaveAs path to '.xlsm' and update the file format parameter to 'xlOpenXMLWorkbookMacroEnabled' instead of 'xlWorkbookDefault'.
Can I save the file to a network drive using a VBA macro?
Yes, you can use a mapped drive letter (such as Z:\) or a direct UNC path (such as \\ServerName\SharedFolder\) in your SaveAs path string to save the workbook directly to a network drive.




