Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using msword9.olb in visual c++ 6.0

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
hi, i dont using word object(com)
pl:
(
Documents doc;
doc.Open(?,?,?) ?
)
VARIANT ???
i want open a *.doc file, i want editing this

Pleas Example
mail: erdos.a@szamalk-inf.hu
(i don't speak good English)
Thanks

 
If you want to use word in your application:
In your project go to Class wizard and select Automation in the Tab,Click the Add class and select from a type library then select msword9.olb from where you installed your winword.After thet in the list shown you can choose what you want to do (If you want only to open an instance of winword you can choose only _Application if you want to manipulate documents you should choose either _Document and Documents or others depending what you want to do with your winword) then Class wizard will create the appropriate classes.
In your App class(Suppose you created a dialog project with Word as name then go to CWordApp class chosse the function InitInstance and add the line:AfxOleInit();
The implementation is as follows, this code will then open a document named "MyDocument.doc"

COleVariant vv(DISP_E_PARAMNOTFOUND, VT_ERROR);
_Application ap;
_Document dd;
Documents dds;
ap.CreateDispatch("Word.Application");
dds=ap.GetDocuments();
dd=dds.Open((COleVariant)"MyDocument.doc",vv,vv,vv,vv,vv,vv,vv,vv,vv,vv,vv);
ap.SetVisible(true);
When you finish you can call:
ap.Quit(vv,vv,vv);
ap.DetachDispatch();
I hope this will be helpfull and I did not any mistakes when writing this.
c.ami@caramail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top