Board index » cppbuilder » Word automation OleServer
Christophe Bourez
![]() CBuilder Developer |
Word automation OleServer2003-06-30 11:49:09 PM cppbuilder56 Hi, 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) where->InsertAfter(StringToOleStr(edText->Text.c_str())); } Can anyone help me ? (FYI, I am working with BCB5 & Word XP under Win2k) TIA Christophe Bourez |