It’s often said that we use only a small proportion of each Office application’s capabilities, and only a minority of users are even aware of the more esoteric parts. The Word VBA implementation attempts to provide visibility to the majority of the extremely extensive object model, and much of its functionality is unused by many VBA developers. Docs targets only the most commonly used parts of Word and as a result, the Apps Script Document service has a much smaller footprint than VBA.
Word has a flat structure, and uses the range object as the principal interface for manipulation. A range is defined internally by its start and end character count address relative to the overall document. The Docs object model is a tree of elements that themselves can contain child elements, with these elements being the main interface. These different approaches mean that there is not as clear a mapping between Word and Docs platform components as there is with Excel and Sheets.
The VBA object model is somewhat muddled, because its flat nature includes some overlap and repetition, as illustrated by Figure 7-1.
The Apps Script model, shown in Figure 7-2, places the element as the main organizational driver.
This chapter will look at the Apps Script object model in some detail, and where possible, show the equivalent VBA approach.
Just like the Spreadsheet app, a script can be container-bound (mainly for use with the current document), or standalone ...