Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Parsing a Word doc with styles
Message
From
07/09/2006 14:48:51
Elyse Pomerantz
Dynamic Data Concepts, Inc.
Brooklyn, New York, United States
 
 
To
07/09/2006 14:28:52
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 8 SP1
Miscellaneous
Thread ID:
01151911
Message ID:
01152024
Views:
23
>>I have a highly-structured Word document that contains many Sections. The first line of every Section is a title with Style "Heading 1" (each section only has one line of "Heading 1"). In VFP I want to get a list of all my Sections by displaying all the lines of Style "Heading 1." (The user will then be able to choose which section(s) they want to print.) How can I do this with Word Automation?
>
>First, if you really mean Sections in the way Word uses the term, you can simply loop through the Sections collection and pull out the first paragraph of each.
>
>However, I think you're using the term "sections" less formally. So, you'll need to cycle through the Paragraphs collection and check the style of each.
>
>FOR EACH oParagraph IN oDocument
> IF oParagraph.Style = "Heading 1"
> cText = oParagraph.Range().Text
> * do something with cText
> ENDIF
>ENDFOR
>
>This may be a little slow, so you might want to try using the Find object instead, and loop through the whole document that way.
>
>Tamar

Actually, I do mean Sections in the way Word uses the term. I've managed to pull out the first paragraph of each Section, but it comes along with a hard return at the end. Is there any way to say "give me the whole paragraph except for the last word"?
Elyse Pomerantz
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform