grep X>Y>..>Z format on word documents


C

cxleung

Hi All

I have 100+ User Manual, in each manual menu selection in below format
X>Y Menu A for ...
run X>Y>1 Menu C update ...
try X>1>A>1 Menu B ...
X>2>A>2 Menu a ....
...
or combination

Some menu in table.
The color of menu selection in blue color

Some to programming grep those menu ?
output format
File name , Menu selection
e.g.
A.doc ,X>Y Menu A
.....

moonhkt
 
Ad

Advertisements

M

moonhkt

Hi All

Below is coding for select Text with color and within color string have ">". It will grep active document with this format.



Sub reportxx()
Dim i As Integer
Dim aDoc As Document
Dim getStr As String
Dim ystr As String
Dim xcolor As Integer
Set aDoc = ActiveDocument
' MsgBox ActiveDocument.Name
xcolor = 0
For i = 1 To aDoc.Characters.Count
If aDoc.Range.Characters(i).Font.ColorIndex <> 0 Then
xcolor = 1
Else
xcolor = 0
End If

If xcolor = 1 Then
If aDoc.Range.Characters(i) <> Chr(13) Then
If getStr = "" Then getStr = ActiveDocument.Name & " - "
getStr = getStr & aDoc.Range.Characters(i)
End If
Else
If InStr(getStr, ">") > 0 Then
If Trim(getStr) <> "" Then
ystr = ystr & getStr & Chr(13)
End If
End If
getStr = ""
End If
Next
MsgBox ystr
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top