LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default AttachDispatch?

Hi,


I scoured the net (including newsgroups) for this info, and nothing I
found worked. Everything had to be heavily modified just to compile,
and the result was still non-functional. Just letting you know I did
my homework before coming here :).

I'm trying to export some data directly to Excel format. I'm using
Excel (2002) on VC++ on an XP system, but would like this to work on as
many versions of Excel and Windows as possible as this will be part of
a shrink-wrapped app.

I was able to get an example from Microsoft's site (which didn't
compile) and modified it. I used xlen32.olb for my type library as I
don't have excel*.olb, and mapped some members (_Application -
Application, GetWorkbooks() - Workbooks(), etc...). But now, I'm
having a problem with AttachDispatch(). Here's the relevant code with
error checking removed for brevity:

Application excel;
excel.CreateDispatch("Excel.Application");
COleVariant covZero((long)0);
COleVariant covDisp = excel.Workbooks(covZero);
Workbooks wbs;
wbs.AttachDispatch(covDisp);

AttachDispatch expects an LPDISPATCH parameter. However, Workbooks
returns a COleVariant. How do I convert from one to the other, or am I
supposed to? GetWorkbooks() -- which should return LPDISPATCH -- is
not a member of Application.

Any help would be greatly appreciated. Even if you can't find what's
wrong with the above, I'll accept links to sites with more info,
snippets of worksheet creation in Excel, etc...


Thanks in Advance.

 
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



All times are GMT +1. The time now is 06:17 AM.

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

About Us

"It's about Microsoft Excel"