C
Carl
Howdy,
I'm trying to get a simple macro to repeat throughout an entire
document. This will be used about once a week on a report. It copies 7
characters out of each page and pastes them to the beginning of the
page. The characters will be different on nearly every page, with a
few repeats. The number of pages will also differ, running anywhere
from 1,000 to 10,000. I'd like to hit a single key to run the job
for the whole job rather then hold it down. I have searched through
the threads, but haven't been able to figure out the solution.
I'm running this on a Windows XP machine with MS Word 2000, and
possibly MS Word '97 on a Win98 machine.
Selection.MoveDown Unit:=wdLine, Count:=3
Selection.MoveRight Unit:=wdWord, Count:=1
Selection.MoveRight Unit:=wdCharacter, Count:=7, Extend:=wdExtend
Selection.Copy
Selection.HomeKey Unit:=wdLine
Selection.MoveUp Unit:=wdLine, Count:=3
Selection.Paste
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Count:=1,
Name:=""
Selection.Find.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
End Sub
I read in a thread that the following code could stop the macro at the
end of a document:
Do
//whatever
Loop Until (Selection.End = ActiveDocument.Content.End - 1)
However I haven't been able to get it to stop the macro and it runs
non-stop until I force Microsoft Word to close.
I was thinking I could get the stop to base on the .Forward of the Goto
Next so that when .Forward = False it stops, but I'm not sure how to
go about coding that.
Any help getting this to work would be greatly appreciated.
Thanks in advance,
Carl Morse.
I'm trying to get a simple macro to repeat throughout an entire
document. This will be used about once a week on a report. It copies 7
characters out of each page and pastes them to the beginning of the
page. The characters will be different on nearly every page, with a
few repeats. The number of pages will also differ, running anywhere
from 1,000 to 10,000. I'd like to hit a single key to run the job
for the whole job rather then hold it down. I have searched through
the threads, but haven't been able to figure out the solution.
I'm running this on a Windows XP machine with MS Word 2000, and
possibly MS Word '97 on a Win98 machine.
Selection.MoveDown Unit:=wdLine, Count:=3
Selection.MoveRight Unit:=wdWord, Count:=1
Selection.MoveRight Unit:=wdCharacter, Count:=7, Extend:=wdExtend
Selection.Copy
Selection.HomeKey Unit:=wdLine
Selection.MoveUp Unit:=wdLine, Count:=3
Selection.Paste
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Count:=1,
Name:=""
Selection.Find.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
End Sub
I read in a thread that the following code could stop the macro at the
end of a document:
Do
//whatever
Loop Until (Selection.End = ActiveDocument.Content.End - 1)
However I haven't been able to get it to stop the macro and it runs
non-stop until I force Microsoft Word to close.
I was thinking I could get the stop to base on the .Forward of the Goto
Next so that when .Forward = False it stops, but I'm not sure how to
go about coding that.
Any help getting this to work would be greatly appreciated.
Thanks in advance,
Carl Morse.