VBA & Macro Problems

Fix Excel Opening Original Workbook When Running Imported Macro

Natalie TaylorNatalie Taylor Nov 2, 2026 868 views

Question details

Running an imported VBA macro in a new Excel workbook unexpectedly triggers the original source workbook to open.

How to Stop Excel from Opening the Original Workbook When Running an Imported Macro
Product
Microsoft Excel
Device & OS
not provided
Scenario
Importing a VBA module (BAS file) into a different workbook and attempting to run the macro using copied buttons, objects, or ribbons.
Observed behavior
The macro or assigned object retains a hidden absolute reference to the original file, causing Excel to automatically open the original workbook whenever the macro is executed.
Before you start

Before proceeding, ensure you have exported your VBA modules as .bas files to a safe location, as the recommended solution involves temporarily removing macros to clear hidden links.

Solution 1Recommended

Save as XLSX and Reimport the Macro

The most effective way to permanently break hidden links to the original workbook is to save the destination file as a standard XLSX file, which strips all embedded VBA links.

By saving the file in a non-macro format, Excel is forced to drop all internal VBA connections. When you reimport the macro afterward, it will be treated as entirely local to the new workbook.

1
Save as a Non-Macro Workbook

Go to File > Save As, and choose 'Excel Workbook (*.xlsx)' from the format dropdown. Confirm any prompts warning you that macros will be removed.

2
Restart the Workbook

Close the newly saved XLSX file completely, and then reopen it in Excel.

3
Reimport the BAS Module

Press ALT + F11 to open the VBA Editor. Go to File > Import File, select your previously saved .bas module, and import it into the clean workbook.

4
Save as Macro-Enabled

Finally, go to File > Save As and select 'Excel Macro-Enabled Workbook (*.xlsm)' to preserve your newly imported macro without the old legacy links.

Save as XLSX and Reimport the Macro
Links Cleared: This method ensures that the workbook itself holds no hidden background references to the original file.
Automate Tasks with WPS Spreadsheet

Seamlessly Manage Macros and VBA in WPS Office

WPS Spreadsheet offers robust support for macros and form controls, allowing you to easily import modules and assign macros to objects without dealing with cumbersome legacy links.

  1. 1. Enable Developer Tools: Open WPS Spreadsheet, go to the Options menu, and enable the Developer tab to access advanced macro tools.
  2. 2. Import VBA Modules: Click the Developer tab, open the VBA Editor, and import your .bas files directly into your current project.
  3. 3. Insert Form Controls: Use the Insert menu under the Developer tab to add fresh buttons, checkboxes, and shapes to your worksheet.
  4. 4. Assign Macros Locally: Right-click the newly inserted object, choose 'Assign Macro', and select the local macro to ensure it runs seamlessly without opening external files.
Full compatibility with Microsoft Excel .xlsm and .bas filesIntuitive Developer tab for easy macro assignment and object creationClean link management to prevent accidental external workbook triggersLightweight application with incredibly fast startup times
microsoft office alternative - wps office

Frequently Asked Questions

Why does my imported macro still look for the old workbook?

When you copy a button, shape, or custom object that has a macro assigned to it, Excel often copies the absolute path of that macro (e.g., 'OriginalFile.xlsm'!MacroName). Clicking it forces Excel to open the old file in order to run that specific script.

Can I just edit the macro assignment instead of recreating the button entirely?

Yes, you can right-click the copied button, select 'Assign Macro', and change the reference from the external file's macro to the macro located in 'This Workbook'. However, starting from scratch is often recommended to prevent hidden workbook links from lingering in the background.

How do I export a macro to a BAS file?

Open the VBA Editor by pressing ALT + F11, locate your module in the Project Explorer panel on the left, right-click it, select 'Export File', and save it as a .bas file to your local computer.

Will saving my file as XLSX permanently delete my macros?

Yes, saving a file in the standard .xlsx format will immediately strip all VBA code and macros from that specific file. This is exactly why it is used to clear hidden links, but you must remember to reimport your .bas module and save the file as .xlsm afterward to restore macro functionality.