Re: Calling Excel from c++
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Sun, 14 Dec 2008 03:58:38 -0500
All Office components export automation interfaces.
The Good News is that these are pretty well documented.
The Bad News is that the documentation is mindlessly hard to use, because it was designed
by people who were clueless about the design of useful documentation. So I can say that
the interfaces are well-documented only if you have the patience to track them down. This
means you bring up Excel, bring up the VBA macro editor, go to its Help, and start down a
tedious (but actually complete) path.
I found the people over in the microsoft.public.office.developer.automation to be
remarkably helpful in giving me the key insights into how documents are organized and what
automation methods you need to use. Once you have that information, you can "translate"
it to the COM methods of the interface.
You can also see some of the code I wrote (including error detection and response) in a
program I wrote called the PowerPoint Indexer, which you can download free from my MVP
Tips site. The core skeleton would be useful for interfacing to any office component, but
the details of the data structures I walk down are obviously PowerPoint rather than Excel
structures. So you'll have to figure out how to find a file, a sheet, a cell, etc., but
once you have figured out the VBA method, you will be able to figure out the MFC classes
you have to import without too much more effort, and what methods to call in them. There's
a bit of a learning curve, but within a couple days you should be able to do something
useful (the hardest part for me was detecting and recovering from errors, if for no other
reason to figure out what I'd coded wrong and fix it, so you'll probably be able to reuse
some of my code for doing that.
joe
On Sun, 7 Dec 2008 22:20:18 -0800 (PST), hamishd <Hamish.Dean@xxxxxxxxx> wrote:
Hi. I want to be able access Excel (read, write, and format data) fromJoseph M. Newcomer [MVP]
within C++.
I have been doing it the other way around (calling c++ dlls from VBA)
and it's just not quite as powerful as i would like.
Any pointers to a good website or something on how to do this?
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- References:
- Calling Excel from c++
- From: hamishd
- Calling Excel from c++
- Prev by Date: Re: About protected memory in COM(in-process)
- Next by Date: Re: Is there a way to disable certain API calls in C++
- Previous by thread: Re: Calling Excel from c++
- Next by thread: VC++ 2008 Feature Pack -> Outlookbar
- Index(es):
Relevant Pages
|