View Single Post
 
Old 09-24-2018, 03:51 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

The problem with what you recorded is that you simply keep deleting characters until you've deleted 17 of them. What you should have recorded is:
Code:
Sub Macro1()
  Selection.Find.ClearFormatting
  Selection.Find.Replacement.ClearFormatting
  With Selection.Find
    .Text = "#"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
  End With
  Selection.Find.Execute
  Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend
  Selection.Delete
End Sub
The line:
Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend
is what you get via Ctrl-Shift-RightArrow, which doesn't require you to know how many characters there are and, moreover, spans everything until the end of the line.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote