Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Trying to install an add in using automatisation directly via C++

Hi,

I'm quite new to automatisation programming and really just want to
touch it (at least right now... ,-)). I've created an Excel-Addin which
gets installed using an installer package. At the end of the
installation process the add-In should be installed in Excel
automagically so the user does not have to care for this.
Using VBA the following two lines would do the job (add some glue code
here):

// AddIns.Add "E:\CreditToolbox\ExcelAddin\build\Managed.XLL "
// AddIns("KreditPricer PLUS").Installed = True

However, I don't have VBA available and I'd like to do it with C++ as
all the other parts of the project are also C++. So I crossed to
solutions from MS at http://support.microsoft.com/kb/q216686/ and
http://support.microsoft.com/kb/196776/ and tried to modify them for my
purpose. The following code is here (the XLL to register is hardcoded
in the example, AutoWrap function is copied from KB216686):

================================================== =======================
// Start server and get IDispatch...this one works
IDispatch *pXlApp;
hr = CoCreateInstance(clsid, NULL, CLSCTX_LOCAL_SERVER, IID_IDispatch,
(void **)&pXlApp);
if(FAILED(hr)) {
::MessageBox(NULL, "Excel not registered properly", "Error",
0x10010);
return -2;
};

// Get Addins collection...this one works
IDispatch *pXlAddins;
{
VARIANT result;
VariantInit(&result);
AutoWrap(DISPATCH_PROPERTYGET, &result, pXlApp, L"AddIns", 0);
pXlAddins = result.pdispVal;
};

// Call the "Add" method and install the Addin
{
VARIANT param;
param.vt = VT_BSTR;
param.bstrVal =
::SysAllocString(L"E:\\CreditToolbox\\ExcelAddin\\ build\\Managed.XLL");
AutoWrap(DISPATCH_METHOD, NULL, pXlAddins, L"Add", 1, param);
VariantClear(&param);
};
================================================== =======================

While the first two calls work, the third fails with the error
0x800a03ec which says something like " [Method name] method of [object]
class failed.".

So what am I missing here, this should be dead simple...



Thanks a lot in advance,
Soeren Gerlach

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
try to install a security update, prompted to install PRO11.msi najib Setting up and Configuration of Excel 0 June 4th 08 05:43 PM
Automatisation - Operations on a table on one line Alexandre Campeau Excel Discussion (Misc queries) 3 May 17th 07 03:30 AM
What program do I install to install office 2003 with no prior pro lwd Excel Discussion (Misc queries) 1 January 8th 06 09:37 PM
Why does PHStats *NOT* install when I install Analytical ToolPak? webeditor-coutre Setting up and Configuration of Excel 1 July 5th 05 06:58 AM
Can I convert directly from excel to RTF? Efanstay Excel Discussion (Misc queries) 2 February 14th 05 06:09 PM


All times are GMT +1. The time now is 11:38 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"