Referencing a dynamic-link library in ArcMap
I built a dynamic link library file VBAPrj.dll under VB6, which has a class of module VBACLS, which has a method test (Doc as Object).
There are three common methods ( author : Zhang):
1. Open the VBA editor, click the References command under the Tools menu, and reference the dynamic link library in the References dialog box.
The calling code is as follows:
Dim Vbacls as New vbaprj.vbacls
Vbacls.test (ThisDocument)
2. If you know the location of the dynamic link library file, you can refer to it in code form in the ThisDocument Code window, as follows:
Private Sub Document_Open ()
On Error Resume Next
Me.VBProject.References.AddFromFile "D:\VBAPrj.dll"
End Sub
3. Copy the dynamic-link library file to the same directory as the document, and you can create the following reference function in the ThisDocument code window:
Private Function Getprojectdoc () as Object
On Error Resume Next
Dim Vbacls as Object
Set Vbacls = CreateObject ("Vbaprj.vbacls")
If Vbacls is Nothing Then
MsgBox "VBAPrj.dll must be in the same directory as the document! "
Exit Function
End If
Set Getprojectdoc = Vbacls
End Function
Then call test in the following code form:
Dim Objprjdoc as Object
Set Objprjdoc = Getprojectdoc
Call Objprjdoc.test (ThisDocument)
Set Objprjdoc = Nothing
Using the first method to debug the hint cannot find the class library, the second method I have not tried, with a third method of debugging success. I also think the third kind of good, in addition to more than a few lines of code. Successful call DLL after the original many in VB write the East simple change can be used in VBA, high efficiency, confidentiality and good
VBA calls DLL dynamic-link library