View Single Post
 
Old 04-06-2021, 01:48 PM
macropod's Avatar
macropod macropod is offline Windows 10 Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Simpler:
Code:
Sub Demo()
Dim Rng As Range
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    'Find from 'Organization:' to the end of the paragraph,
    ' but not including the paragraph break
    .Text = "Organization:[!^13]{1,}"
    .Replacement.Text = ""
    .Format = False
    .Forward = True
    .Wrap = wdFindStop
    .MatchWildcards = True
    .Execute
  End With
  If .Find.Found = True Then
    'Move the Start to ':',
    ' then a further two characters
    .MoveStartUntil ":", wdForward
    .Start = .Start + 2
    'Store the current range
    Set Rng = .Duplicate
    'Find & Replace 'CIO' in the current range
    With .Find
      .Text = "CIO"
      .Replacement.Text = "CIB"
      .Execute Replace:=wdReplaceOne
      'Report the outcome as it applies to the stored range
      If .Found = True Then
        Rng.Copy
        MsgBox """" & Rng.Text & """copied"
      Else
        MsgBox """" & Rng.Text & """NOT copied"
      End If
    End With
  End If
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote