Introduction to. Net word programming objects

Source: Internet
Author: User
Tags printable characters

Word object model:

Application Object

The Application Object indicates the word application, which is the parent of all other objects. All its members are generally applied to word as a whole. You can use the attributes and methods of this object to control the word environment.

 

Document Object

Microsoft. Office. InterOP. Word. Document objects are the hub of word programming. When you open a document or create a new document, a new Microsoft. Office. InterOP. Word. Document object is created, which is added to the documents set of word. The document in focus is called the activity document, which is represented by the activedocument attribute of the Application object.

Selection object

The selection object indicates the selected region. When you perform an operation (for example, bold text) on the word user interface, you must first select or highlight the text and then apply the format settings. The selection object always exists in the document. If no object is selected, it indicates the insertion point. In addition, it can be a nonconsecutive number of text blocks.

Range object

The range object indicates a continuous area in the document, which is defined by a starting character position and an ending character position. The number of range objects is not limited to one. You can define multiple range objects in the same document. The range object has the following features:

  • Its composition can be a separate insertion point, or a text range or entire document.
  • It contains non-printable characters, such as spaces, tabs, and paragraph tags.
  • It can be the region of the selected region or the region outside the selected region.
  • Unlike the selected content, the content is invisible in the document.
  • It does not save as a document and only exists during code running.
  • When you insert text to the end of a range, word automatically expands the range to include the inserted text.
Bookmark object

Microsoft. Office. InterOP. Word. bookmark in the document is the easiest way to control text in the document, which is similar to text box controls on Windows Forms. The Microsoft. Office. InterOP. Word. Bookmark object indicates a continuous area in the document with both the start position and end position. Bookmarks are used to mark a location in a document or as a text container in the document. The Microsoft. Office. InterOP. Word. Bookmark object can be as small as one insertion point or as large as the entire document. Microsoft. Office. InterOP. Word. Bookmark differs from the range object in that it has the following features:

You can name bookmarks during design.

The Microsoft. Office. InterOP. Word. Bookmark object is saved along with the document. Therefore, it is not deleted when the code is stopped or the document is closed.

Bookmarks can be hidden or visible by setting the showbookmarks attribute of the view object to true or false.

Optional parameters in Excel and Word

When you use Visual Basic to program word or Excel, you do not have to pass a value for each optional parameter because the default value is automatically used for each parameter without a parameter value. However, optional parameters are not supported in C #, so values must be passed for each parameter in the method. Microsoft Visual Studio 2005 tools for the Microsoft Office System project contains a global variable named missing, which is specified in the generated code as system. type. Missing. You can pass this global variable as the default value for each optional parameter.

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.