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

Discussion in 'Word Programming' started by cxleung@gmail.com, Oct 28, 2011.

  1. Guest

    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
     
    , Oct 28, 2011
    #1
    1. Advertisements

  2. moonhkt Guest

    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
     
    moonhkt, Nov 19, 2011
    #2
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.