Implement Word 97 automation with C + + Builder

Source: Internet
Author: User
Tags ole

To control Word97 running in an application, you must first include the file comobj.hpp in the header file when you compile the Automation client, and write to #include. Programming tools C++builder Developers have roughly packaged the functionality of calling Word97 Automation objects into several Oleobjectclass functions that application designers can easily exploit.

* Set the properties of the OLE object:

Olepropertyget (propname)

Olepropertyset (Propname,value)

Where value is any value that can be converted to variant type

* Method of calling OLE object:

Oleprocedure (Oleprocname,[val,...])

Olefunction (Olefuncname,[val,...])

Where Val is any value that can be converted to a variant

----can be passed olefunction (Olefuncname,[val,...]) The parent object returns its child object, which is the syntax: the child object name = The parent object name. Olefunction (Olefuncname,val). This method can also be used to combine objects from the parent object that return their underlying objects.

----C++builder uses OLE Automation control WORD97, you must master Word97 's Automation objects and the Microsoftwordvisualbasic Help file's object methods and properties for Word. A Word object represents an element of word, such as a document, paragraph, bookmark, or individual character. A collection is an object that contains several other objects, usually of the same type, for example, a collection object that can contain all the bookmark objects in the document. By using properties and methods, you can modify individual objects, or you can modify the entire collection of objects. A property is an attribute of an object or an aspect of the object's operation. For example, a document property contains a name, content, save state, and whether or not revisions are enabled. To change the properties of an object, you can modify the value of the property. Method is an action that an object can perform.

----The automation objects that represent the WORD97 application are two: Word.Application and Word.Basic, the WordBasic property of the Application object allows them to be transformed between assignments. By using Createoleobject ("...") in C++builder, you can start Word and get a handle and assign it to a Variant variable. If there are two variant variants V1 and V2,wordbasic are properties of the Application object:

V1=createoleobject ("Word.Application");

V2=v1. Olefunction ("WordBasic").

----The following is a simple example of how to implement WORD97 Automation in C++builder by opening or creating a new document, sending text to the current activity, inserting a bitmap, and drawing a line. Under the C++builder integrated development environment IDE, create a project Project1 that contains the cell file Oleautomation Form1 (which is caption Unit1.cpp). The filter of the OpenDialog1 object for the form Form1 is set to a Word document or bitmap. Unit1.cpp must contain "COMOBJ.HPP" in the header file. The code is as follows:

Related Article

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.