Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

OLE Automation of MS Word From C++ Builder 3.0

89 views
Skip to first unread message

David Boyd

unread,
Jan 11, 1999, 3:00:00 AM1/11/99
to
I'm driving MS Word from a C++ Builder App, using OLE automation. We have to
print detailed documents, but only specified text of these documents change
each time. So we created templates. The Application creates a new Word
Document based on the template just fine, and I can insert text into the
document.

The problem is, I can't get the app to send the cursor to a specific
bookmark set in the document.

There are several Bookmarks in the doc template. Once the cursor gets to
that position I can Insert text. Or if I can get a bookmark range variant
object, I can use it's InsertAfter method.

Here is the code we currently have:

Variant MSApp;
MSApp = Variant::CreateObject("word.Application");
MSApp.OlePropertySet("Visible",true);
Variant MSWord_Disclosure = Variant::CreateObject("word.basic");
String s_template = "\"C:\\docs\\Disclosure2.dot\"";
MSWord_Disclosure.OleProcedure("FileNew", s_template, 0);

// Need to go to existing bookmark called "FirmCode"

// Then insert text there..
MSWord_Disclosure.OleProcedure("Insert", "Firm Code Goes Here.");

Or We could somehow create a new Variant containing a bookmark range.
and then:

// need to ceate a bookmark object containing the "FirmCode" bookmark.
(MSBookMark)

// Then Insert text there...
MSBookmark.OleProcedure("InsertAfter", "Firm Code Goes Here.");


Any help filling this gap for us much appreciated.

Thanks in advance,

David


0 new messages