bejhan
asked on
Checking For A Reference
I have a mapped network drive M:\ which is mapped to Domain\\Folder
I have a dll included in my references. The dll is located in the same location as the application.
I want a few checks in place:
First of all I want to check if the reference is pointing the the same directory as the application (in case the folder was ever moved). If it is not I want to use the currentproject.path to set the reference location. The problem is currentproject.path returns M:\applocation... but reference.fullpath returns Domain\\Folder\applocation ..., so when comparing these strings they would not be equal. How can I get one to "change its ways". Also how would I detect this, would the database refer to this reference as broken? If so, I know how to detect this otherwise I don't know where to begin. And how would I change the path of the reference via vba code.
Second, if the user does not have the dll registered in their system the code will give an error. If there is an error I want to use regsvr32.exe to install it (via call shell). Is there a better way to detect its absence besides waiting to get to the error prone code?
I have a dll included in my references. The dll is located in the same location as the application.
I want a few checks in place:
First of all I want to check if the reference is pointing the the same directory as the application (in case the folder was ever moved). If it is not I want to use the currentproject.path to set the reference location. The problem is currentproject.path returns M:\applocation... but reference.fullpath returns Domain\\Folder\applocation
Second, if the user does not have the dll registered in their system the code will give an error. If there is an error I want to use regsvr32.exe to install it (via call shell). Is there a better way to detect its absence besides waiting to get to the error prone code?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry, missed the declarations.
To list the referencenses, run:
Call ListReferences
/gustav
To list the referencenses, run:
Call ListReferences
/gustav
' Declarations and functions for creating and storing
' a list (table) of the current References.
'
' 2001-08-20. Cactus Data ApS, CPH.
' Length of GUID string per definition.
Private Const clngGUID As Long = 38
Type GuidDefinition
Guid As String * clngGUID
Major As Integer
Minor As Integer
End Type
' Minimum Guid version.
Private Const cintMajorMinVersion As Integer = 1
Private Const cintMinorMinVersion As Integer = 0
Public Sub ListReferences()
Dim ref As Reference
' List current references.
For Each ref In References
With ref
Debug.Print .Guid & ", " & .Major & ", " & .Minor & ", " & .Name & ", " & .FullPath
End With
Next
Set ref = Nothing
End Sub
ASKER
Okay and if the reference is broken how do I repair it with a new path, etc.?
If it is registered no path is needed, just its GUID.
/gustav
/gustav
ASKER
If booSuccess = True Then
' Return actual GUID version.
typGuid.Major = .Major
typGuid.Minor = .Minor
End If
What would I put in an else clause here to repair the broken reference?