Error handling if VBA reference not found?

JumboCactuar

Well-known Member
Joined
Nov 16, 2016
Messages
609
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
 

Jaafar Tribak

Well-known Member
Joined
Dec 5, 2002
Messages
7,407
Office Version
2016
Platform
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
If it is a standard dll , you could look into the LoadLibrary API and check its result .
 

JumboCactuar

Well-known Member
Joined
Nov 16, 2016
Messages
609
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:

Jaafar Tribak

Well-known Member
Joined
Dec 5, 2002
Messages
7,407
Office Version
2016
Platform
Windows
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.
 

Forum statistics

Threads
1,077,664
Messages
5,335,566
Members
399,025
Latest member
alce

Some videos you may like

This Week's Hot Topics

Top