Error handling if VBA reference not found?

JumboCactuar

Well-known Member
Joined
Nov 16, 2016
Messages
788
Office Version
  1. 365
Platform
  1. Windows
Hi,
I have an Excel macro that requires a reference (DLL) and if the DLL isn't found I get "Compile Error, can't find project or library"

Is there a way I can handle this error by checking if the DLL exists then msgbox / exit sub

Thanks for any help
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Hi,
I have an Excel macro that requires a reference (DLL) and if the DLL isn't found I get "Compile Error, can't find project or library"

Is there a way I can handle this error by checking if the DLL exists then msgbox / exit sub

Thanks for any help

If it is a standard dll , you could look into the LoadLibrary API and check its result .
 
Upvote 0
If it is a standard dll , you could look into the LoadLibrary API and check its result .

Thanks for the reply, though it isnt a standard DLL

The DLL when installed will always be located at the same location, so thinking I can simply check if file exists.
 
Last edited:
Upvote 0
Thanks for the reply, though it isnt a standard DLL

The DLL when installed will always be located at the same location, so thinking I can simply check if file exists.

You could then use the Dir function.

Also, you may want to look into the VBProject.References and look for the reference name in the loop as well as the IsBroken Property.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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