![]() |
|
#1
|
||||
|
||||
![]()
In what sense? Do you want the tag before the period, or after, as it is now? On the assumption you want the tags before the period (etc.), try:
Code:
Sub Demo() Application.ScreenUpdating = False Dim ArrFnd, i As Long, wdDoc As Document Set wdDoc = ActiveDocument wdDoc.ActiveWindow.View.ShowFieldCodes = True ArrFnd = Array("must", "shall") For i = 0 To UBound(ArrFnd) Call TagIt(wdDoc, ArrFnd(i), "R") Next ArrFnd = Array("may", "should") For i = 0 To UBound(ArrFnd) Call TagIt(wdDoc, ArrFnd(i), "M") Next With wdDoc .Fields.Update .ActiveWindow.View.ShowFieldCodes = False End With Application.ScreenUpdating = True End Sub Sub TagIt(wdDoc As Document, strFnd As Variant, strTag As String) Dim RngTag As Range With wdDoc.Range With .Find .ClearFormatting .Replacement.ClearFormatting .Text = strFnd .Replacement.Text = "" .Forward = True .Wrap = wdFindStop .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False .Execute End With Do While .Find.Found Set RngTag = .Duplicate With RngTag .End = .Sentences.First.End - 2 While Not .Characters.Last.Next.Text Like "[.!?]" .End = .End - 1 Wend While (.Characters.Last = Chr(19)) Or (.Characters.Last = Chr(23)) .End = .End - 1 Wend .Collapse wdCollapseEnd End With .Fields.Add RngTag, wdFieldEmpty, "SEQ " & strTag & " \# '[" & strTag & "'000']'", False .Collapse wdCollapseEnd .Find.Execute Loop End With End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Word table - how do I append % symbol to each value in columns 3 & 4 of a table | Dawsie | Word | 4 | 03-06-2013 12:33 AM |
![]() |
AlmostFriday | Word | 6 | 06-17-2012 05:21 AM |
![]() |
ubns | Word | 1 | 05-31-2012 10:38 PM |
![]() |
flexible | Word | 2 | 05-03-2012 02:25 AM |
Append text to a cell with color | gvdm | Excel | 1 | 04-17-2012 10:21 AM |