Summary
This article describes how to automatically open and print a Microsoft Word document in Visual c++5.0 or 6.0.
More information
You can copy the code in the article to the event definition message handler in your own MFC. cpp file. However, the code is primarily intended to illustrate how to handle IDispatch interfaces and member functions that are defined in the Msword8 type library. By reading and understanding the code, you can modify these examples or write programs that open and print Microsoft Word documents.
Because some of the methods and properties in Word2000 have changed, read more: New changes in the Office type library
To create a project step
1. In Microsoft Word, create a new document, add some text, and save it as a test.doc. Closes the document and exits word.
2. Based on the methods provided in the 1-12 steps of the article in the following Knowledge base, we use the IDispatch interface and its member functions defined in the Msword8.olb type library to create the sample project.
How to create an Automation project using MFC and type libraries
3. Add the following line at the top of the AutoProjectDlg.cpp:
#include "msword8.h" // msword9.h for Word 2000, msword.h for Word 2002