Recurse Word Object Model Redux

T

Trevor Lowing

Or...should I be looking at the Word Document Model in a more generic
fashion? If the list below shows a generic model for a document, how
should I access all the other object such as shapes. lists, tables, etc
to dump them in the correct order?


Document
Sections
Section
Headers
Header
Paragraphs
Paragraph
Sentences
Sentence
Words
Word
Footers
Footer

---------------------------------
Trevor Lowing
Satellite Beach, Fl

(e-mail address removed)
---------------------------------
Need help with:
Access?
http://www.mvps.org/access/
Outlook?
http://www.slipstick.com/
Visio?
http://www.mvps.org/visio/
HTML/CSS?
http://www.NCDesign.org
Scripting(VBScript/JScript/WSH/XML)?
http://www.DevGuru.com
http://cwashington.netreach.net/
http://developer.irt.org/script/script.htm
---------------------------------
 
K

Klaus Linke

Hi Trevor,

Some remarks:

-- I'd look at how StoryRanges figure into this.

-- Whether you treat paragraphs as parts of the doc (as in your first list) or as part of sections (your second list) is a matter of choice, depending on what you want to do. In the VBA help, you can see Paragraphs can be accessed from the Document, Selection, or some Range. If you want to create some hierarchy for accessing all objects in a doc, the "natural" parent would, IMO, be the StoryRange (as a special case of a Range).

-- Shapes and floating tables will probably be problematic if you want to traverse a document, "collecting" all objects.
Best consult the VBA help on where they may appear (say, Shapes as part of other Shapes, ShapeRanges, ...).

-- I wouldn't deal with Words and Sentences if it can be avoided. Both are calculated on the fly, and that takes a lot of time that's usually wasted, because few macros need to deal with text on that level.

HTH,
Klaus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top