【发布时间】:2017-04-29 00:39:27
【问题描述】:
我最近获得了一段基于 2003 的 Office 版本并且基于 32 位的 VBA 代码。我只有 64 位 Office 2016,我将代码更新到下面 - 但是当我运行宏时,我得到一个“运行时错误 - 找不到文件”Swings4-2.dll”。即使我删除了文件扩展名仍然会弹出错误。DLL 文件与 XLS/XLSM 文件位于同一目录中,即使我引用了文件的完整目录 - 它仍然给我一个错误。
#If VBA7 And Win64 Then
Private Declare PtrSafe Sub Swings Lib "Swings4-2.dll" (ByRef Par1 As Integer, ByRef Par2 As Integer, _
ByRef Par3 As Single, ByRef Par4 As Single, ByRef Par5 As Single, ByRef Par6 As Single, _
ByRef Par7 As Single, ByRef Par8 As Single, ByRef Par9 As Single, ByRef Par10 As Single, _
ByRef Par11 As Single, ByRef Parl2 As Single, ByRef Parl3 As Single, ByRef Parl4 As Single)
#Else
Private Declare Sub Swings Lib "Swings4-2.dll" (ByRef Par1 As Integer, ByRef Par2 As Integer, _
ByRef Par3 As Single, ByRef Par4 As Single, ByRef Par5 As Single, ByRef Par6 As Single, _
ByRef Par7 As Single, ByRef Par8 As Single, ByRef Par9 As Single, ByRef Par10 As Single, _
ByRef Par11 As Single, ByRef Parl2 As Single, ByRef Parl3 As Single, ByRef Parl4 As Single)
#End If
我们将不胜感激
【问题讨论】:
-
以管理员权限打开命令提示符。输入“regsvr32 path\swings4-2.dll”(省略引号,将path替换为dll文件的路径)。如果 dll 之神与我们同在,这将解决问题。
-
不确定是否可以从 64 位 VBA 运行时调用 32 位 dll...
-
@Tim Williams 我的理解是你可以。参见例如stackoverflow.com/questions/5724396/…
-
我认为需要 64 位或“任何 CPU”编译的 dll 吗?例如见cadsharp.com/blog/solidworks-macro-compatible-64-vba7 和knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/…