craig20120
asked on
Word Plugin w/ MFC / ATL - How to modify text contents of active document.
I have a MS Word plugin using MFC and ATL. I know how to get a pointer to the Word active document. I can save the document, etc., but how can I get access to the text contents of that document to modify it then save it.
Thanks!!
Thanks!!
ASKER
Question... "It can be VBA code". Is that a question or a statement?? I don't know how to call VBA code from C++.
Thanks!
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes, I can use those functions. Not sure of the syntax though. Do you have the C++ code.
No, I haven't C++ cod.e It can be something like that:
CRange* rngRange = pDocumentt->Range(pDocumen tt->Paragr aphs(1)->S tart(), pDocumentt->Paragraphs(1)- >End() - 1);
rngRange->InsertAfter(" This is now the last sentence in paragraph one.");
CRange* rngRange = pDocumentt->Range(pDocumen
rngRange->InsertAfter(" This is now the last sentence in paragraph one.");
ASKER
Does rngRange represent the actual word document itself? In other words, if I save it to a database, I can read it back out again??
Thanks!!
Thanks!!
ASKER
Disregard, the last comment. Thanks for your help.
...
"Use the InsertAfter or InsertBefore method to insert text before or after a Selection or Range object. The following example inserts text at the end of the active document."
...
It can be /VBA code/
Set doc = ActiveDocument
Set rngRange = _
doc.Range(doc.Paragraphs(1
rngRange.InsertAfter _
" This is now the last sentence in paragraph one."
http://support.microsoft.com/default.aspx/kb/222101
http://www.codeguru.com/cpp/misc/misc/article.php/c6091/