U
USAFA
I'm trying to find the text throughout a document and perform an action (go
to the beginning of the line & backspace 5 times) to take out space in my
document. After it does this I want it to continue performing these steps
(loop I guess) throughout the document, but I don't want it to stop once it
reaches the end of the document.
I need to use this macro on documents that range from 2 pages to 50 pages in
length. Please assist.
Here's my code so far:
Sub Step1()
Dim oRng As Range
Set oRng = ActiveDocument.Range
With Selection.Find
.Text = " ***************** PERSONAL"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
Selection.Find.Execute
Selection.HomeKey Unit:=wdLine
Selection.TypeBackspace
Selection.TypeBackspace
Selection.TypeBackspace
Selection.TypeBackspace
Selection.TypeBackspace
Selection.MoveRight Unit:=wdCharacter, Count:=6
Selection.EndKey Unit:=wdLine
End With
End Sub
to the beginning of the line & backspace 5 times) to take out space in my
document. After it does this I want it to continue performing these steps
(loop I guess) throughout the document, but I don't want it to stop once it
reaches the end of the document.
I need to use this macro on documents that range from 2 pages to 50 pages in
length. Please assist.
Here's my code so far:
Sub Step1()
Dim oRng As Range
Set oRng = ActiveDocument.Range
With Selection.Find
.Text = " ***************** PERSONAL"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
Selection.Find.Execute
Selection.HomeKey Unit:=wdLine
Selection.TypeBackspace
Selection.TypeBackspace
Selection.TypeBackspace
Selection.TypeBackspace
Selection.TypeBackspace
Selection.MoveRight Unit:=wdCharacter, Count:=6
Selection.EndKey Unit:=wdLine
End With
End Sub