Results 1 to 20 of 51

Thread: verify start and end tags

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #7
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,476
    Location
    I don't know if this is any help, but here's some rough code to list all the tag codes. I think with a little (maybe a lot) more work you could record the tags and add/reduce a tab count which could produce an indented listing.
    Regards
    MD

    [VBA]Sub Tags()
    Dim MyData(100)
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
    .Text = "<"
    .Replacement.Text = "xx"
    .Forward = True
    .Wrap = wdFindContinue
    .MatchWildcards = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
    .Text = ">"
    .Replacement.Text = "zz"
    .Forward = True
    .Wrap = wdFindContinue
    .MatchWildcards = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    Selection.Find.ClearFormatting
    Selection.HomeKey Unit:=wdStory

    For i = 1 To 99
    With Selection.Find
    .Text = "xx*zz"
    .MatchWildcards = True
    .Forward = True
    .Wrap = wdFindStop
    End With
    Selection.Find.Execute
    MyData(i) = Mid(Selection.Text, 3, Len(Selection.Text) - 4)
    Next
    With Selection.Find
    .Text = "xx"
    .Replacement.Text = "<"
    .Forward = True
    .Wrap = wdFindContinue
    .MatchWildcards = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    With Selection.Find
    .Text = "zz"
    .Replacement.Text = ">"
    .Forward = True
    .Wrap = wdFindContinue
    .MatchWildcards = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    Documents.Add
    For i = 1 To 100
    Selection.TypeText MyData(i) & vbCr
    Next
    End Sub

    [/VBA]
    Last edited by mdmackillop; 01-31-2006 at 02:28 PM. Reason: Loop error corrected
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

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