Quantcast
Channel: Word for Developers forum
Viewing all articles
Browse latest Browse all 4350

Word 2013 Macro to insert a page break after every other text "Date"

$
0
0

Good morning,

I am trying to write a macro to insert a page break after every other word it sees called "Date" Each section has 2 texts "Date" and i need the macro to insert after the 1st time it recognizes it. I wrote this to insert at every text"Date"

            

Selection.HomeKey Unit:=wdStory
    With Selection.Find
        .Text = "Date"
        .Forward = True
    End With

    Do
        Selection.Find.Execute
        If Selection.Find.Found = True Then
                Selection.InsertBreak Type:=wdPageBreak

            End If

    Loop While Selection.Find.Found = True
End Sub

Any help would be greatly appreciated. Can you also tell me how to have it insert at the test "Date" and not replace the word with a page break?

Thank you,


Viewing all articles
Browse latest Browse all 4350

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>