A Few Last Words on Smart Documents
Now that you’ve seen the parts involved, it’s worth considering which aspects of Smart Documents need your focus.
Range and Selection Objects
The Word object model consists of hundreds
of objects, yet no two are more powerful than
range
and selection
. These two
objects are used to identify the parts of the document that are to be
manipulated by the accompanying code. What is confusing is that, for
most cases, either object can be used. The main difference is that a
range
is not visible to the end user; that is, you
can identify a range and manipulate it, and the end
user’s cursor location will not move.
selection
, on the other hand, does exactly what
you’d expect—literally highlighting the
selection on the end user’s screen. More often than
not, range
is preferred over
selection
for several reasons, not the least of
which is performance.
Both the range
and selection
objects have dozens of properties and methods associated with
them—everything from cut, insert, and delete to XMLNodes. For a
thorough explanation of range
and
selection
, see
Writing
Word Macros by Steven Roman (O’Reilly).
Inserting Markup
One of the powerful features of Word is its ability to quickly change the “view” of any document on the screen. You can turn individual formatting markers on or off, change the overall look from outline to print layout, view field codes or placeholder text. What may not have been apparent in the past but now becomes clearly evident is what, if ...
Get Office 2003 XML now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.