Programatically Trap Missing Reference Compile Error upon Opening Excel Macro

darrendrake

New Member
Joined
Aug 29, 2017
Messages
3
I have a scenario where I am attempting to convert .xlsm files to .xlsx.

Scenario:
1. Browse to a folder with say 500 .xlsm files
2. Open each file, strip out the macro code and save as a non-macro enabled file(.xlsx).​

I have code that achieves the above scenario; however, all of the .xlsm files have references to third party tools that no longer exist in my environment.

This has created missing references. I have attempted to remove the references programmatically. However, each time I attempt to programmatically open one of the .xlsm files from my controlling macro file I receive a compile error in the .xlsm file that is attempting to open. The error states, “Can’t find project or library.” This is because the .xlsm file has missing references.

As you can imagine opening 500 files manually to remove stale object library references is a daunting task.

I tried trapping the error, but the error is actually thrown in the file that is attempting to open opposed to the one from which I am initiating the open command. This is the source of my frustration.

Area where help is needed:

I am looking for suggestions as to how to programmatically deal with the compilation error generated upon opening the various .xlsm files. Assuming this is possible, I am looking for help with trapping the error that occurs in the opening .xlsm file from the controlling macro file, so that I can divert the focus to my procedure that removes the stale references.

I hope this make sense and appreciate any assistance anyone may provide.
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
I haven't ever tried it, but have you tried using application.automationsecurity = msoAutomationSecurityForceDisable to disable all macros in files you open and then simply save as xlsx? You shouldn't need to actually run or remove any code yourself other than opening and saving if you do that.
 
Upvote 0
Rory, thanks for the response.

I have not tried that which you have suggested. I don't believe it will solve my immediate issue of dealing with the compile errors that are thrown when opening the files. The errors are thrown in response to missing references. This is the issue that I am looking to resolve.
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,260
Members
452,627
Latest member
KitkatToby

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top