2011-04-21 91 views
3

我试图创建只是一个简单的XLL文件,但我不能 我已经按照在MSDN网站 http://support.microsoft.com/kb/178474 的教程,但本教程是为Microsoft Excel 97开发工具包,我只是有版本2007 的Visual Studio 2005中,所以这也许是什么导致错误:如何为excel创建一个xll?

1>------ Build started: Project: Anewxll, Configuration: Debug Win32 ------ 
1>Compiling... 
1>Anewxll.cpp 
1>c:\nam\test\anewxll\anewxll\anewxll.cpp(97) : error C2665: 'AfxMessageBox' : none of the 2 overloads could convert all the argument types 
1>  c:\program files\microsoft visual studio 8\vc\atlmfc\include\afxwin.h(5031): could be 'int AfxMessageBox(LPCTSTR,UINT,UINT)' 
1>  c:\program files\microsoft visual studio 8\vc\atlmfc\include\afxwin.h(5033): or 'int AfxMessageBox(UINT,UINT,UINT)' 
1>  while trying to match the argument list '(const char [21], long)' 
1>c:\nam\test\anewxll\anewxll\anewxll.cpp(140) : error C2665: 'AfxMessageBox' : none of the 2 overloads could convert all the argument types 
1>  c:\program files\microsoft visual studio 8\vc\atlmfc\include\afxwin.h(5031): could be 'int AfxMessageBox(LPCTSTR,UINT,UINT)' 
1>  c:\program files\microsoft visual studio 8\vc\atlmfc\include\afxwin.h(5033): or 'int AfxMessageBox(UINT,UINT,UINT)' 
1>  while trying to match the argument list '(char [8192], long)' 
1>c:\nam\test\anewxll\anewxll\anewxll.cpp(174) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [14]' to 'LPCWSTR' 
1>  Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast 
+2

更新的文档和SDK http://msdn.microsoft.com/en-us/library/aa730920%28v=office.12%29.aspx – 2011-04-21 15:55:30

回答

3

您拥有的错误消息与Excel或Excel SDK无关。前两个错误是由于您使用了AfxMessageBox(一个MFC API),第三个错误是因为与Win32消息框API的参数不匹配。这些错误是由于您的项目是一个Unicode应用程序(导致TCHAR评估为wchar_t和诸如MessageBox的评估为MessageBoxW的宏而不是MessageBoxA)导致的。最简单的解决方法是将您的应用程序从Unicode更改为MBCS。

但是,如果我可以提出建议,请考虑使用Add-in express或ExcelDNA来创建UDF/RTD。我猜你对Win32 C++编程不太舒服。如果是这种情况,用普通的C++和Excel SDK创建UDF/RTD/Addins会遇到很多麻烦。

如果您使用附加的express或excel dna,他们会将所有令人头疼的问题转化为直观的.net类型和其他各种管道,让您可以专注于业务逻辑。

免责声明:我与加载项快递或excel dna没有任何关系。我刚刚碰巧使用过它们。