Results 1 to 4 of 4

Thread: Error handling if VBA reference not found?

  1. #1
    Board Regular
    Join Date
    Nov 2016
    Posts
    607
    Post Thanks / Like
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)

    Default Error handling if VBA reference not found?

    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

  2. #2
    Board Regular Jaafar Tribak's Avatar
    Join Date
    Dec 2002
    Location
    Larache--Morocco
    Posts
    7,353
    Post Thanks / Like
    Mentioned
    39 Post(s)
    Tagged
    3 Thread(s)

    Default Re: Error handling if VBA reference not found?

    Quote Originally Posted by JumboCactuar View Post
    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 .
    Office/Excel 2010 64Bits -- Win10 64Bits

    Common sense is not so common.


    http://photo-larache.blogspot.com/

  3. #3
    Board Regular
    Join Date
    Nov 2016
    Posts
    607
    Post Thanks / Like
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Error handling if VBA reference not found?

    Quote Originally Posted by Jaafar Tribak View Post
    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 by JumboCactuar; Aug 26th, 2019 at 07:56 AM.

  4. #4
    Board Regular Jaafar Tribak's Avatar
    Join Date
    Dec 2002
    Location
    Larache--Morocco
    Posts
    7,353
    Post Thanks / Like
    Mentioned
    39 Post(s)
    Tagged
    3 Thread(s)

    Default Re: Error handling if VBA reference not found?

    Quote Originally Posted by JumboCactuar View Post
    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.
    Office/Excel 2010 64Bits -- Win10 64Bits

    Common sense is not so common.


    http://photo-larache.blogspot.com/

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •