nam
nam

Reputation: 3632

How to create a xll for excel?

I'm trying to create just a simple xll file but I can not I've followed the tutorial in the msdn site http://support.microsoft.com/kb/178474 But this tutorial is for Microsoft Excel 97 Developer's Kit, i just have the version 2007 an visual studio 2005, so this is maybe what cause the error:

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

Upvotes: 3

Views: 3931

Answers (2)

quixver
quixver

Reputation: 574

The error messages that you have are not related to Excel or the Excel SDK. The first 2 errors are due to your usage of AfxMessageBox (an MFC API) and the 3rd is because of parameter mismatch with the Win32 message box API. These errors are caused because your project is an Unicode application (causing TCHAR to evaluate to wchar_t and macros such as MessageBox to evaluate to MessageBoxW as opposed to MessageBoxA). The simplest fix would be to change your application from Unicode to MBCS.

However - if I may make a suggestion - consider using Add-in express or ExcelDNA to create your UDF/RTDs. I am guessing you are not very comfortable with Win32 C++ programming. If that is the case you will face a lot of trouble creating UDFs/RTDs/Addins with plain C++ and the Excel SDK.

If instead you go with add-in express or excel dna - they take care of all the headaches of converting xlopers to intuitive .net types and other assorted plumbing, leaving you free to concentrate on your business logic.

Disclaimer: I am in no way associated with either add-in express or excel dna. I have just happened to have used them on and off.

Upvotes: 3

Keith A. Lewis
Keith A. Lewis

Reputation: 771

If you can install MSVC++ 2010 Express then http://xll.codeplex.com willsave you a lot of trouble.

Upvotes: 2

Related Questions