- Joined
- Sep 8, 2016
- Messages
- 12
- Reaction score
- 1
Searching for days trying to find a solution as my code only highlights to the end of the line (as shown below).
I've come across some other commands but not sure how to formulate.
<code>
Sub Find_Highlight_Word_to_End_of_Line()
'BUT NEED IT TO HIGHLIGHT THROUGH END OF PARAGRAPH
Dim sFindText As String
'Start from the top of the document
Selection.HomeKey wdStory
sFindText = "Contractor Shall"
Selection.Find.Execute sFindText
Do Until Selection.Find.Found = False
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Range.HighlightColorIndex = wdYellow
Selection.MoveRight
Selection.Find.Execute
Loop
End Sub
</code>
(ideally, highlighting the below paragraph AND the list that provides further details below the paragraph would be best -but if only the paragraph is achievable, that's better than nothing)
Sample Text Where Lists Exist (and would be nice to pick up in the highlighting):
"The Contractor shall turn in monthly status reports within ten business days after the end of each month. The report should include:
(a) Accomplishments
(b) Meetings and Outcomes
(c) Completed Travel and Purpose of Travel"
I've researched several commands and looked for examples but still at a loss as a novice.
I tried "wdParagraph" instead of "wdLine" but couldn't get that to work.
Located refs of maybe using a "paragraph.range.select" and also found a note that advised these "start" and "end" terms (below) to select a paragraph.. but not sure how to achieve this?
* Selection.StartOf Unit:=wdParagraphm
* Selection.MoveEnd Unit:=wdParagraph
Hoping someone has an example of how to accomplish this as it will help greatly with quickly identifying hundreds of software reqs out of a 100 page word doc.. so frustrated!
I've come across some other commands but not sure how to formulate.
<code>
Sub Find_Highlight_Word_to_End_of_Line()
'BUT NEED IT TO HIGHLIGHT THROUGH END OF PARAGRAPH
Dim sFindText As String
'Start from the top of the document
Selection.HomeKey wdStory
sFindText = "Contractor Shall"
Selection.Find.Execute sFindText
Do Until Selection.Find.Found = False
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Range.HighlightColorIndex = wdYellow
Selection.MoveRight
Selection.Find.Execute
Loop
End Sub
</code>
(ideally, highlighting the below paragraph AND the list that provides further details below the paragraph would be best -but if only the paragraph is achievable, that's better than nothing)
Sample Text Where Lists Exist (and would be nice to pick up in the highlighting):
"The Contractor shall turn in monthly status reports within ten business days after the end of each month. The report should include:
(a) Accomplishments
(b) Meetings and Outcomes
(c) Completed Travel and Purpose of Travel"
I've researched several commands and looked for examples but still at a loss as a novice.
I tried "wdParagraph" instead of "wdLine" but couldn't get that to work.
Located refs of maybe using a "paragraph.range.select" and also found a note that advised these "start" and "end" terms (below) to select a paragraph.. but not sure how to achieve this?
* Selection.StartOf Unit:=wdParagraphm
* Selection.MoveEnd Unit:=wdParagraph
Hoping someone has an example of how to accomplish this as it will help greatly with quickly identifying hundreds of software reqs out of a 100 page word doc.. so frustrated!