Board index » cppbuilder » Word automation OleServer

Word automation OleServer

2003-06-30 11:49:09 PM
Before posting, I do a lot of researches on the web and newsgroups but
without success. This issue seems to be BCB specific.
I am using OleServer objects to connect to Word. I'd like to retrieve the
range associated to a bookmark in my document.
After investigating header files, I can't figure out what I need to pass to
the function Item of Bookmarks property. Item()requires a TVariant * as
parameter. But I get an exception when calling Item() (after debugging step
by step, I get an error from COM interfaces (HR = 0x800A1735)). I assume
that I don't call Item correctly.
Word and Document are component on my form.
TWordApplication *Word;
TWordDocument *Document;
// my code
std::string bookmark("MyBookmark");
if (Document->Bookmarks->Exists( StringToOleStr(bookmark.c_str()) ))
TVariant varIndex( bookmark.c_str() );
RangePtr where = Document->Bookmarks->Item( &varIndex )->Range; //
causes exception
if (where)
Can anyone help me ?
(FYI, I am working with BCB5 & Word XP under Win2k)
Christophe Bourez

Re:Word automation OleServer

Hi Stew,
Great, it works fine now ;-)
Thank you very much for your help!
Christophe Bourez