VBA中调用dll文件的路径问题

来源:互联网 发布:sm town演唱会知乎 编辑:程序博客网 时间:2024/05/17 23:24

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

原创粉丝点击