logo
search
VBA & Macro Problems

How to Save an Excel Workbook to Another Drive with VBA

Nimra MalikNimra Malik Oct 10, 2026 870 views

Question details

The user needs to automate saving an active Excel workbook to a specific drive or directory using VBA.

How to Save an Excel Workbook to Another Drive with 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.
Before you start

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.

Solution 1Recommended

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.

1
Open the VBA Editor

Press Alt + F11 to open the Visual Basic for Applications (VBA) editor in Excel.

2
Insert a New Module

Click on 'Insert' in the top menu and select 'Module' to create a new script area.

3
Write the SaveAs Macro

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.

4
Run the Macro

Press F5 or click the Run button to execute the script and verify that the workbook has been saved to the target drive.

Use the Workbook.SaveAs Method with a Complete File Path
Syntax Check: Make sure to include the trailing backslash in your folder path (e.g., C:\VBA Folder\) to avoid incorrectly concatenating the folder name with the file name.
WPS Spreadsheet Macro Support

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. 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. 2. Open the VBA Editor: Navigate to the Developer tab on the ribbon and click 'Visual Basic', or simply press Alt + F11.
  3. 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.
Fully compatible with Microsoft Excel VBA syntax and objectsSupports saving and opening .xls, .xlsx, .xlsm, and .xlsb formats nativelyLightweight application that runs complex macros quicklyFree and intuitive interface for an effortless transition
microsoft office alternative - wps office

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.