I am using VBA to parse a large set of Word documents, and I want to make sure that their structure follows certain rules (eg you cannot have more than one paragraph between tables, table nesting can only go down one level (ie you can have a table in a table, but no further nesting), and so on (this is not a complete list!)).
So I thought I would step through the "elements" in each document, looking for these patterns, but I have been unable to do so. All looping solutions seem to focus on one type of object, and I don't see any easy way to do that here. When I look at a document, I see (eg) a header, then three paragraphs, then a table, then a paragraph, then two tables, and so on; I would like my VBA to be able to step through the document in the same way. Is it possible?
I am very experienced in Excel VBA but just starting out in Word VBA, so still trying to understand the concepts and the object model -- please forgive my ignorance!
[EDIT] In the end I found that the best way to accomplish what I wanted was to use VBA to Save As HTML; that saves the structure as it is in the document. I can then parse the HTML, looking for the structural elements that I want. Sounds a little roundabout, I agree, but it's fairly quick and does the trick.