VBA & Macro Problems

How to Save an Excel Workbook Copy Using VBA While Keeping the Original Open

Chanuka GeekiyanageChanuka Geekiyanage Nov 2, 2026 870 views

Question details

The user wants to save a copy of an active Excel workbook to a specific directory using VBA while ensuring the original workbook remains open and active for continued editing.

Product
Excel
Device & OS
not provided
Scenario
Using a VBA macro to automatically back up or duplicate a workbook without interrupting the current workflow.
Observed behavior
Using the SaveCopyAs method sometimes yields unexpected results or corrupt files if an incorrect or unsuitable file extension is specified in the VBA code.
Before you start

Ensure you have the Developer tab enabled in your spreadsheet program and that your current workbook is saved in a macro-enabled format (.xlsm) before writing and executing VBA code.

Solution 1Recommended

Use the SaveCopyAs Method with a Valid File Extension

The easiest and most reliable way to create a copy without affecting your active session is using the built-in SaveCopyAs VBA method.

The ActiveWorkbook.SaveCopyAs method saves a copy of the workbook to a specified file but does not modify the open workbook in memory. The key to avoiding corruption is ensuring the file extension matches the workbook's format (e.g., using .xlsm for a macro-enabled file).

1
Open the VBA Editor

Press ALT + F11 on your keyboard to launch the Visual Basic for Applications editor in your spreadsheet program.

2
Insert a new module

Right-click on your workbook name in the Project Explorer window on the left, select Insert, and then click Module.

3
Write the SaveCopyAs code

Create a new macro by typing `Sub SaveCopy()` and pressing Enter. Inside the sub, add your code: `ActiveWorkbook.SaveCopyAs Filename:="C:\YourDirectory\YourFilename.xlsm"`. Be absolutely sure to use the .xlsm extension if your original file contains macros.

4
Run the macro

Press F5 or click the green Run button at the top to execute the code. A duplicate file will be generated in your target folder, while your original file stays completely open and active.

Use the SaveCopyAs Method with a Valid File Extension
Verify File Extensions: If you are saving a standard workbook without macros, use the .xlsx extension. Mismatched extensions are the primary cause of unreadable files when using SaveCopyAs.
Advanced Spreadsheet Capabilities

Run VBA Macros Seamlessly in WPS Spreadsheet

WPS Office provides robust native support for VBA macros in its advanced editions, allowing you to automate tasks like saving workbook copies without interrupting your workflow.

  1. 1. Open your macro-enabled workbook: Launch WPS Spreadsheet and open your .xlsm file.
  2. 2. Access the Developer tab: Navigate to the 'Tools' tab on the ribbon and click 'Developer' to reveal the macro toolset.
  3. 3. Launch the VBA Editor: Click 'VBA Editor' to open the environment, paste your SaveCopyAs code, and run it just like you would in Excel.
100% compatible with Microsoft Excel .xlsm and .xlsx formatsFully supports VBA (Visual Basic for Applications) and complex macro executionLightweight application that loads heavy macro-enabled workbooks exceptionally fastClean, tabbed user interface for easy multitasking
microsoft office alternative - wps office

Frequently Asked Questions

Why does SaveCopyAs corrupt my Excel file or make it unreadable?

This usually happens if you specify an incorrect file extension in your VBA code. For example, forcing a .xlsx extension on a workbook that contains macros will result in a corrupted copy. Always ensure the extension string in your code matches the actual file type.

Does the SaveCopyAs method change my active workbook?

No, SaveCopyAs simply exports a copy to the specified destination in the background. Your original workbook remains open, active, and untouched on your screen.

How do I add a timestamp to the copied filename in VBA?

You can dynamically concatenate the current date and time using the Format function in VBA. For example: `ActiveWorkbook.SaveCopyAs "C:\Backups\MyFile_" & Format(Now, "yyyymmdd_hhmmss") & ".xlsm"`.