Fix an Excel Macro After Renaming or Copying a Workbook
Question details
Restore a macro that behaves differently after its Excel workbook is renamed or copied.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A user renames or duplicates a macro-enabled workbook and wants to run its VBA macro.
- Observed behavior
- The macro stops working or behaves differently, even though the workbook folder is listed as a trusted location.
Confirm that the renamed or copied file has a macro-enabled extension such as .xlsm, and identify the macro that no longer works. Check whether Excel displays a security warning when you open the file.
Clear the workbook author property and retest the macro
Try clearing the Author field as a reported workaround, then reopen the workbook to see whether it resolves the issue.
In Excel, open the affected workbook and select File > Info > Properties > Advanced Properties.
On the Summary tab, clear the Author field and select OK.
Save and close the workbook, reopen it, and run the macro from Developer > Macros. Check whether it now behaves as expected.

Check the macro-enabled format and Excel security settings
Use these checks when the macro is unavailable or Excel blocks VBA content after the file is copied.
Update workbook references in the VBA code
Check the code when the macro runs but refers to the old workbook name, location, or an unintended active workbook.
Work with Excel spreadsheets in WPS Office
WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and Microsoft Office format compatibility for an easier move between apps. It does not fix Excel's macro security or workbook settings, and VBA support can vary by platform and version.

Frequently Asked Questions
Why would a macro stop working after I rename a workbook?
The VBA code may refer to the original filename or path. Open Developer > Visual Basic and look for hard-coded references to the old name.
Does a trusted folder guarantee that my macro will run?
No. The workbook must still contain the macro, and its code and references must be valid. File-origin restrictions or organizational policies can also affect macro behavior.
What is the difference between ThisWorkbook and ActiveWorkbook in VBA?
ThisWorkbook refers to the workbook containing the running code. ActiveWorkbook refers to the workbook currently active in Excel, which may be a different file.
Can I recover a macro by saving an .xlsx file as .xlsm?
Changing the file type back to .xlsm does not restore VBA code that was removed. Open a copy that still contains the macro, then use File > Save As to save it in a macro-enabled format.




