J
Julia
Hi, can't figure out why the following code deletes my document, one
character at a time!
It needs to simply search for the next page break, move one character to the
right, select until it hits a space and delete the selection, which happens
to be several blank paragraphs at the top of each page. It works fine
without the looping, but I just can't get it to work. Can you help???
Thanks much
With Selection
.WholeStory
.ExtendMode = False
.Collapse
End With
With Selection.Find
.ClearFormatting
.Text = "^m"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
While .Execute
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.Extend
With Selection.Find
.Text = " "
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Wend
End With
End Sub
character at a time!
It needs to simply search for the next page break, move one character to the
right, select until it hits a space and delete the selection, which happens
to be several blank paragraphs at the top of each page. It works fine
without the looping, but I just can't get it to work. Can you help???
Thanks much
With Selection
.WholeStory
.ExtendMode = False
.Collapse
End With
With Selection.Find
.ClearFormatting
.Text = "^m"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
While .Execute
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.Extend
With Selection.Find
.Text = " "
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Wend
End With
End Sub