Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing DLLs through VBA

Tags:

excel

vba

dll

How can I access the functions inside a third-party DLL from VBA (Excel)? Also, is there a way to see what all functions are available inside a DLL?

like image 876
KJ Saxena Avatar asked Apr 28 '11 17:04

KJ Saxena


1 Answers

To call a function in a third-party DLL, you need to use the Declare statement. For example:

Private Declare Function GetTempPath Lib "kernel32" _
     Alias "GetTempPathA" (ByVal nBufferLength As Long, _
     ByVal lpBuffer As String) As Long

See How to: Access DLLs in Excel on MSDN for more information.


To list the functions that are available, take a look at the Dependency Walker tool, which will list the exported functions from DLLs (and lots of other information).

like image 66
Justin Avatar answered Nov 13 '22 01:11

Justin