Open and print Word documents using automation

Source: Internet
Author: User
Tags knowledge base

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.