View Single Post
 
Old 08-22-2018, 03:12 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
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

Actually, the basic problem with your code is that you're explicitly telling the Find to act on the whole document, not just the selected range. Graham's code does likewise, but the .Text = " A2" Find expression works only because your selection is the only range that contains that string. Try:
Code:
Sub FixReferences()
With Selection.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Text = " A2"
  .Replacement.Text = "^pA2"
  .Forward = True
  .Format = False
  .Wrap = wdFindStop
  .MatchWildcards = True
  .Execute Replace:=wdReplaceAll
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote