vba Dll

原网址:http://blog.sina.com.cn/s/blog_4aee288a0100d15q.html

Today I have met some problems on specifying a relative path into a excel vba header, linking a dll.You must specify a absolute one instead of the relative path.

For example:

Declare Function LoadProject Lib "C:\Program Files\AccessHist.dll" (ByVal projectpath As String) As Boolean

At last I found the solution, just put the dll in the same folder as the xls file and in the Workbook_open() function put the following:

chdrive(thisworkbook.path)
chdir(thisworkbook.path)

You can linking the dll like this way:

Declare Function LoadProject Lib "AccessHist.dll" (ByVal projectpath As String) As Boolean 

猜你喜欢

转载自blog.csdn.net/sunnyxidian/article/details/8902078
vba
dll