Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 553
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default 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" wrote in message
...
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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" wrote in message
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Test if file exists Daniel Bonallack Excel Discussion (Misc queries) 2 May 4th 09 04:19 PM
Test if Sheet Exists - Tom Ogilvy Steph[_3_] Excel Programming 8 September 23rd 04 04:37 AM
Test for Worksheet Exists bcmiller[_8_] Excel Programming 4 July 2nd 04 11:46 AM
Test if folder exists, create if it doesn't? 43fan Excel Programming 1 March 1st 04 04:31 PM
Test if a folder exists Jeff Marshall Excel Programming 6 September 30th 03 05:21 PM


All times are GMT +1. The time now is 11:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"