VBA learning summary

zhaozj2021-02-16  87

Today, I made a VBA practice on Word, and now I will summarize it. Today, I use the four objects in the Word, Document, Selection, Range these four objects, Application, and Document have nothing to say, the key use is Selection, Range. SELECTION follows the Range to represent an object selected on the Word, which is also very useful for the content of the Word on Word, but only the Selection object on each document, and the Range object can have Multiple. SELECTION can not be generated with New, but you can return Selection objects, there are many ways to return this object, today I use Range.select to return, when you perform this method, you can reference the Selection in the document. To represent the Selected area of ​​the range representation, for the reason I often use today is the movement of the cursor, which can be implemented by Move, Endof, Startof, etc., these methods have three parameters, one is a Unit table is mobile Unit, count moves how many units, extend represents whether or not to move or move, this parameter has two constants WDEXTEND, WDMOVE. When you have a Selection object, you can do it for the selected area. The Range object is obtained by the Range property of the document object, or by specifying a new RANGE to generate a regional range of the active document. This allows you to operate as using the Selection object after you get a RANGE.

转载请注明原文地址:https://www.9cbs.com/read-15984.html

New Post(0)