Fix Excel Custom Ribbon Macro Buttons Opening the Wrong Workbook
Question details
Users need to correct custom ribbon buttons that trigger macros from the original workbook instead of the current one after copying or migrating a macro-enabled file.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Copying, renaming, or migrating a macro-enabled Excel workbook that contains user-created custom ribbon buttons.
- Observed behavior
- When clicking a custom ribbon button in the new workbook, Excel incorrectly opens the original file to run the macro, rather than executing the macro housed inside the current workbook.
Ensure both your original and new workbooks are saved as Macro-Enabled Workbooks (.xlsm) and that the Developer tab is enabled in your Excel ribbon.
Manually Reassign Macros to Custom Ribbon Buttons
The quickest and most reliable fix is to remove the outdated ribbon buttons in the new workbook and re-add them, assigning them directly to the current workbook's macros.
When you assign a macro to a ribbon button in Excel, the application often binds it to the absolute file path of the workbook. If the workbook is duplicated or renamed, the ribbon button still looks for the original path.
Open the copied workbook in Excel. Go to 'File' in the top-left corner, select 'Options' at the bottom, and click on 'Customize Ribbon' in the left pane.
In the right-hand list (Main Tabs), locate the custom group containing your broken macro buttons. Select the faulty buttons and click the 'Remove' button in the middle column.
In the left-hand column under 'Choose commands from', click the dropdown menu and select 'Macros'. This will display a list of all macros available in the current workbook.
Select the correct macro from the list, ensure your custom group is highlighted on the right, and click 'Add'. You can click 'Rename' to give the button a user-friendly name and a custom icon.
Click 'OK' at the bottom of the Excel Options window to save your updated ribbon configuration. Test the button to ensure it runs without opening the old file.

Update Callback References in CustomUI.xml (Advanced)
For workbooks utilizing a custom XML-based ribbon modification, edit the internal CustomUI file to remove hardcoded workbook name references.
Manage and Run VBA Macros Easily in WPS Spreadsheet
Avoid complex ribbon reference issues by utilizing WPS Spreadsheet. It provides a straightforward Developer tab to manage, edit, and run your VBA macros seamlessly, offering high compatibility with Microsoft Excel macro-enabled workbooks.
- 1. Open Your Workbook: Launch WPS Spreadsheet and open your macro-enabled workbook (.xlsm).
- 2. Access Developer Tools: Navigate to the 'Developer' tab on the main ribbon interface.
- 3. Open Macros List: Click the 'Macros' button to open a dialog displaying all available VBA procedures associated with the current file.
- 4. Run Macro Directly: Select the required macro from the list and click 'Run'. This executes the code safely within the current workbook, bypassing any broken ribbon links.

Frequently Asked Questions
Why do custom ribbon buttons point to the old Excel file?
When you assign a macro to a custom ribbon button, the software often binds it to the absolute file path of that specific workbook. When the workbook is copied, the button retains that exact path and searches for the original file when clicked.
Can I prevent macro buttons from linking to the old workbook in the future?
Yes. Instead of attaching macros to custom ribbon buttons, you can trigger them using Form Controls or ActiveX command buttons placed directly on the spreadsheet itself. These controls travel safely with the workbook without retaining absolute external path links.
Does renaming the workbook cause the same macro link issue?
Yes. If the ribbon customization explicitly referenced the old filename, simply renaming the workbook will break the button. It will attempt to search for the old name, either throwing an error or opening an older backup file if it exists in the same folder.
How do I easily remove broken custom ribbon groups?
Go to File > Options > Customize Ribbon. Find your custom group in the right-hand panel, right-click it, and select 'Remove'. You can then create a fresh group and assign the local macros to it.




