PDA

View Full Version : Highlight specifc text plus 15 characters afterwards



gentle2005
10-17-2016, 11:47 PM
Hi,

1. I would like to highlight all the words "Specification" and "red marked"(30 characters) items along with it in the attached file. It has 1000+ pages. Need macro to highlight all occurrences. i.e(specification+30characters)

2. Is it possible to insert the Red marked Specification into the table next to "Range" column in word?

3.Can we export the specification along with 30 characters and its file name as separate column in excel file?


Please through some VBA action into this task.

gmayor
10-18-2016, 04:26 AM
1: -

Sub HighlightSpec()
Dim oRng As Range
Set oRng = ActiveDocument.Range
With oRng.Find
.Font.ColorIndex = wdRed
Do While .Execute(Forward:=True)
If Len(oRng) > 1 Then
oRng.Start = oRng.Start - 14
oRng.HighlightColorIndex = wdTurquoise
'Debug.Print oRng.Text
End If
oRng.Collapse 0
Loop
End With
lbl_Exit:
Exit Sub
End Sub

2: - No idea what that means
3: - Probably, but you'll have to clarify what exactly you want and where you want it.
Within the loop, oRng.text is the specification and the preceding characters.
Which Filename?

gentle2005
10-18-2016, 09:03 AM
Thanks. I am sorry I could not explain you well .Actually I want to convert the attached word file into excel data list as attached.