LAST TIME: HOW DO I MAKE THIS MACRO LOOP
LAST TIME: HOW DO I MAKE THIS MACRO LOOP
(OP)
Sorry for not making things clearer in my previous posts and my explanation as to why the problem has not been solved would be too wordy. So I apologize for my previous posts on this and truly appreciate previous input. I finally have this macro perfected like I want. The macro was created in Word and once a document is opened it arrows down twice, finds the word "REPORT", and once it's found, close search window, cursor up one line and press End key to get to the end of that line then Ctrl-Enter to force a page break. Please tell me exactly what and where to put it into this macro to make it keep running until the end of the file and stop. Thank you so much. Here is the code:
Sub Macro1()
'
' Macro1 Macro
'
'
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.Find.ClearFormatting
With Selection.Find
.Text = "REPORT"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveUp Unit:=wdLine, Count:=1
Selection.EndKey Unit:=wdLine
Selection.InsertBreak Type:=wdPageBreak
Selection.MoveDown Unit:=wdLine, Count:=2
End Sub
Sub Macro1()
'
' Macro1 Macro
'
'
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.Find.ClearFormatting
With Selection.Find
.Text = "REPORT"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveUp Unit:=wdLine, Count:=1
Selection.EndKey Unit:=wdLine
Selection.InsertBreak Type:=wdPageBreak
Selection.MoveDown Unit:=wdLine, Count:=2
End Sub
RE: LAST TIME: HOW DO I MAKE THIS MACRO LOOP
Also state what the finished product should look like page break wise.
Skip,
Just traded in my OLD subtlety...
for a NUance!
RE: LAST TIME: HOW DO I MAKE THIS MACRO LOOP
Cheers
Paul Edstein
[MS MVP - Word]
RE: LAST TIME: HOW DO I MAKE THIS MACRO LOOP
Have you tried it?
If so: what exactly does it NOT do the way you want it to?
have you tried putting it in a module in your document like this
CODE -->
P.S: Please respond here, do not open yet another thread, especially not all-caps or with an added "!Arghhh!"
"Knowledge is power. Information is liberating. Education is the premise of progress, in every society, in every family." (Kofi Annan)
Oppose SOPA, PIPA, ACTA; measures to curb freedom of information under whatever name whatsoever.
RE: LAST TIME: HOW DO I MAKE THIS MACRO LOOP
RE: LAST TIME: HOW DO I MAKE THIS MACRO LOOP
RE: LAST TIME: HOW DO I MAKE THIS MACRO LOOP
CODE -->
RE: LAST TIME: HOW DO I MAKE THIS MACRO LOOP
Find = (^13)([!^13]@REPORT@[^13])
Replace = \1^012\2
or:
Find = (^13)([!^13]@ANNUAL REPORT@[^13])
Replace = \1^012\2
No macros or loops required! Of course, if tombaraider really, really, really wants a macro, there's always the macro recorder...
Cheers
Paul Edstein
[MS MVP - Word]
RE: LAST TIME: HOW DO I MAKE THIS MACRO LOOP
CODE
Selection.Find.Replacement.ParagraphFormat.PageBreakBefore = True With Selection.Find .Text = "report" .Replacement.Text = "" .Forward = True .Format = True .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll
RE: LAST TIME: HOW DO I MAKE THIS MACRO LOOP
I actually opened a word document, typed =rand() to get some sample text, 'sprinkled' some 'REPORT' words in it and tried the macro.
Yes, it does Find on the word "REPORT", but then
- moves the cursor one line up
- moves the cursor to the end of the line
- inserts a page break
- moves the cursor 2 lines down
That's a different action that simply "replace word REPORT with a PageBreak"...Have fun.
---- Andy
A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
RE: LAST TIME: HOW DO I MAKE THIS MACRO LOOP
Skip,
Just traded in my OLD subtlety...
for a NUance!
RE: LAST TIME: HOW DO I MAKE THIS MACRO LOOP
RE: LAST TIME: HOW DO I MAKE THIS MACRO LOOP
RE: LAST TIME: HOW DO I MAKE THIS MACRO LOOP
RE: LAST TIME: HOW DO I MAKE THIS MACRO LOOP
>Of course, I can tweak it in VBA.
You've been given several VBA solutions that only require minor tweaking between your changes of requirements. So tweak ...
RE: LAST TIME: HOW DO I MAKE THIS MACRO LOOP
RE: LAST TIME: HOW DO I MAKE THIS MACRO LOOP
RE: LAST TIME: HOW DO I MAKE THIS MACRO LOOP
Cheers
Paul Edstein
[MS MVP - Word]
RE: LAST TIME: HOW DO I MAKE THIS MACRO LOOP