+ Reply to Thread
Results 1 to 3 of 3

How to test if a DLL (library) exists

  1. #1
    ExcelMonkey
    Guest

    How to test if a DLL (library) exists

    How do I test in VBA to see if a particual DLL exists in my references? I
    want to test to see if the RegExp library exists and if so I want to check it
    off. If it does not exist I want o generate an error message prompting the
    user that the file is not available in the libraries.

    On a side note, I am assuming that the library should be available. Why
    would it not be? Is there any reason that xl97 upward would not have this?
    And if it is not available, what are the users options (assuming this may be
    driven by version of Excel). For example, say the user had it but
    accidentally deleted it. What would they need to do to restore it?

    Thanks

  2. #2
    Rob Hargreaves
    Guest

    Re: How to test if a DLL (library) exists

    Hi xlmonkey

    If you open the vb editor window and go to tools and then references you
    will see the referenced dlls in the dialog that comes up.

    Depending on what you are doing you will have to know which will be ticked
    in the list.

    You cannot get to this option in debug mode.

    you can check for any file at a known path through vba

    Sub FileExists()
    Dim fso
    Dim file As String
    file = "C:\Test.xls" ' change to match the file w/Path
    Set fso = CreateObject("Scripting.FileSystemObject")
    If Not fso.FileExists(file) Then
    MsgBox file & " was not located.", vbInformation, "File Not Found"
    Else
    MsgBox file & " has been located.", vbInformation, "File Found"
    End If
    End Sub

    You could maybe use a shell command through vba to register or unregister
    dlls as librarys through vba.

    I have done it with regsrv for windows files before but only through
    start... run... dialogue in the windows start bar.

    Search google forr info on this.

    Hope that helps

    Rob

    "ExcelMonkey" <[email protected]> wrote in message
    news:[email protected]...
    > How do I test in VBA to see if a particual DLL exists in my references? I
    > want to test to see if the RegExp library exists and if so I want to check
    > it
    > off. If it does not exist I want o generate an error message prompting
    > the
    > user that the file is not available in the libraries.
    >
    > On a side note, I am assuming that the library should be available. Why
    > would it not be? Is there any reason that xl97 upward would not have
    > this?
    > And if it is not available, what are the users options (assuming this may
    > be
    > driven by version of Excel). For example, say the user had it but
    > accidentally deleted it. What would they need to do to restore it?
    >
    > Thanks
    >





  3. #3
    Bob Phillips
    Guest

    Re: How to test if a DLL (library) exists

    Give this a whirl

    Dim ref As Object
    Dim fRef As Boolean

    fRef = False
    For Each ref In ThisWorkbook.VBProject.References
    If ref.Name = "VBScript_RegExp_55" Then
    Debug.Print ref.Name
    ThisWorkbook.VBProject.References.Remove ref
    fRef = True
    End If
    Next
    If Not fRef Then MsgBox "No ref set"


    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "ExcelMonkey" <[email protected]> wrote in message
    news:[email protected]...
    > How do I test in VBA to see if a particual DLL exists in my references? I
    > want to test to see if the RegExp library exists and if so I want to check

    it
    > off. If it does not exist I want o generate an error message prompting

    the
    > user that the file is not available in the libraries.
    >
    > On a side note, I am assuming that the library should be available. Why
    > would it not be? Is there any reason that xl97 upward would not have

    this?
    > And if it is not available, what are the users options (assuming this may

    be
    > driven by version of Excel). For example, say the user had it but
    > accidentally deleted it. What would they need to do to restore it?
    >
    > Thanks




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1