ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Direct DLL reference? (https://www.excelbanter.com/excel-programming/399977-direct-dll-reference.html)

XP

Direct DLL reference?
 
Is there a way, using VBA to directly reference a DLL?

Please note, I'm NOT looking for code that selects a reference in Tools then
References, but instead allows a direct DLL call.

If so, your example code would be appreciated.

Thanks much.

Chip Pearson

Direct DLL reference?
 
See the Declare statement. E.g.,

Public Declare Function MyFunction Lib "FileName.dll" (Args As Whatever) As
Long

Sub AAA()
Dim Res As Long
Res = MyFunction(123,456)
End Sub

Note that (1) you cannot call functions in a DLL created in VB with this
syntax. VB can create only ActiveX DLLs that must be created as objects. (2)
the DLL function must have been compiled with the __stdcall directive, (3)
the function must have been included in the DEF file.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"XP" wrote in message
...
Is there a way, using VBA to directly reference a DLL?

Please note, I'm NOT looking for code that selects a reference in Tools
then
References, but instead allows a direct DLL call.

If so, your example code would be appreciated.

Thanks much.




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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com