VBA calls DLL dynamic-link library

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.