[RESOLVED] Word Selecting text under a heading
All i'm asking is for a push in the right direction here. :)
In this document, the headings and text are all a specific style. How might i select a range of text/tables from 1 heading to the line just b4 the next heading? It would be nice if i could go through line by line and check if the text is a certain style (ie a heading) then record that position. Once i have the positions i'm in easy street!
VB Code:
r = d.Range(Start:=startPos, End:=endPos)
I will be needing to iterate through all the headings in the document which isn't that hard conceptially, I'm just lost in the amount of methods and properties the document object has :(
Much Love!
Re: Word Selecting text under a heading
Hi there,
not sure about being able to pick specific places in a document to search between (unless you place bookmarks in the document maybe in the Heading lines), but maybe i can help you a bit.
The following code shows how to loop through & record the styles for Paragraphs, Words & Tables.
They where the only collections i could think of that might be of some use to you, there isn't one for lines that i can find anyway.
VB Code:
Sub test()
Dim n As Integer
Dim strParagraphStyle() As String
Dim strWordsStyle() As String
Dim strTablesStyle() As String
For n = 1 To ActiveDocument.Paragraphs.Count
ReDim strParagraphStyle(n)
strParagraphStyle(n) = ActiveDocument.Paragraphs.Item(n).Style
Next
For n = 1 To ActiveDocument.Words.Count
ReDim strWordsStyle(n)
strWordsStyle(n) = ActiveDocument.Words.Item(n).Style
Next
For n = 1 To ActiveDocument.Tables.Count
ReDim strTablesStyle(n)
strTablesStyle(n) = ActiveDocument.Tables.Item(n).Style
Next
End Sub
hope it's of some use !
Re: Word Selecting text under a heading
Thanks a heap!
- Much Love