Results 1 to 2 of 2

Thread: VBA Word Macro Wants to Work on Subrosa Style Property

  1. #1

    Question VBA Word Macro Wants to Work on Subrosa Style Property


    I have some very long documents I’m working with - 800+ pages.

    I’m using custom styles to add comments.

    Since they files are so long being able to jump to the next instance of formatting is more efficient than scrolling for 50 pages or more to the next any Style.

    The formats are all visually unique - each indicates some other action that needs to be taken.

    So, I just need to be able to go from page 40 t0 99 to…137 to 151 to 238… basically just jump to the next any instance of formatting.

    Following great help here at EE this is what I’ve got as a solution:

    Create a parent Word style that is unique unto itself. Not based on any other text in the document.

    Set a background property of the Parent Style - for instance Character Spacing - to a unique value, lets say 0.05.

    Use this newly created, and slightly modified - Style as the "Based On" property for all the other commenting Styles, so that all the custom highlighting Styles in my document are children of this one.

    The KEY to this strategy is having made a SMALL modification to the Parent that will get propagated to every child highlighting style, but ALSO wont interfere with the UNIQUE aspects of each markup style.

    So that the Green Font Style and the Trajan Font All Caps Style and the Purple Highlight Style all stay visibly unique. They only share one SMALL inherited characteristic from the Parent - I chose Font > Advanced > Character Spacing +.05

    With them all sharing this hidden / behind-the-scenes feature, the a Macro can be written to look ONLY for that and - BOOM! I can jump forward to ANY next highlight with just a keyboard shortcut.

    I've NEARLY got this solved! Here is the problem I'm facing:

    Attached is a smalpe file: The last paragraph of pages 1, 2, 3, 4, 6, 7 & 8 all have the _Child Style, with 0.5 Character Spacing. inherited from the Parent.

    Running the macro below only jumps to pages pages 1, 3, 6 & 8.

    Sub ot3()
    ' ot3 Macro
        With Selection.Find
            .Text = ""
            .Font.Spacing = 0.5
            .Format = True
            .Forward = True '<< change True to False for the "go backwards" macro
            .Wrap = wdFindStop
            If .Found = False Then
                MsgBox "No more found.", vbInformation, "Going forward..."
            End If
        End With
        ActiveDocument.ActiveWindow.ActivePane.SmallScroll Up:=6
    End Sub
    Also, it SEEMS like there's a flicker when I run the Macro - like the search is touching the OTHER pages with the style, but then skipping forward.

    So close on getting this. Just can't seem to figure out what I'm missing.


    Last edited by Flinorandee; 06-18-2020 at 07:42 AM.

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Jul 2008
    Paul Edstein
    [Fmr MS MVP - Word]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts