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
本文详细介绍了在使用Excel VBA时遇到的DLL路径问题,从相对路径转换为绝对路径的方法。通过将DLL文件放置在与Excel工作簿同一文件夹内,并在Workbook_open()函数中进行相应的代码调整,实现了正确的DLL链接。

被折叠的 条评论
为什么被折叠?



