【发布时间】:2014-03-18 05:10:50
【问题描述】:
我正在尝试从简单的 Word for Mac 宏中调用存储在简单 dylib 文件中的简单函数,
我在 OS-X Mountain Lion 上使用 Xcode5 创建 .dylib,并从 Word for Mac 2011 中调用它。
首先是libWord.dylib:
Test.h
#ifndef __Word__Test__
#define __Word__Test__
bool testFunc();
#endif
Test.cpp
#include "Test.h"
bool testFunc(){
return true;
}
和宏:
字宏
Private Declare Function testFunc Lib "/Users/usrName/Documents/libWord.dylib" () As Boolean
Sub TestLibFunc()
Dim b As Boolean
b = testFunc
StatusBar = b
End Sub
宏可以找到dylib(我已经放在上面的目录中了),但是一直抛出:
“运行时错误‘453’: 找不到指定的 DLL 函数”
我也尝试过将函数声明为类的一部分:
class testClass{
static bool testFunc();
}
bool testClass::testFunc(){
return true;
}
然后尝试使用上面的 Declare 语句和一个别名来调用它:
Private Declare Function testFunc Lib "/Users/usrName/Documents/libWord.dylib" Alias "testClass::testFunc" () As Boolean
我还尝试将库路径名中的“/”替换为“:”,所有这些都给出了相同的结果。
那么,我错过了什么?就我所见过的所有例子而言:
VBA Shell function in Office 2011 for Mac
Return string to VBA in MacOSX
上述应该工作(以同样的方式遥控器应该就在你离开它的地方)。 但显然我一定做错了什么,任何关于在哪里看的指针都会受到欢迎(越明显和羞耻越好)。
【问题讨论】: