Macro for new paragraph on next page after page break RRS feed

  • Question

  •   I don't know anything about writing macros. I copied one for putting a page break on every page. I insert jpgs of scanned documents in word, macro to resize them to fit one document per page. Then I use the page break macro to separate the images. I need a new paragraph to start on the following page after each page break before the image for tittling. I want it to be "Documents/Return to Narrative". I can record a macro for this, but I don't know how to insert it for every page. I don't want to use headers, footers,or captions. The reseason? I have files I report on that can be 100's to 1000's of pages. 

    Can I add a string to this page break macro or is there one I can have that will work separately? 

    Sub Pagebreaks()
    Sub InsertPageBreakOnEachPageInDoc()
      Dim objPageRange As Range
      Dim nTotalPageNumber As Integer
      Dim nPageNumber As Integer

      Application.ScreenUpdating = False

      nTotalPageNumber = ActiveDocument.ComputeStatistics(wdStatisticPages)

      For nPageNumber = nTotalPageNumber To 1 Step -1
        Set objPageRange = ActiveDocument.GoTo(wdGoToPage, wdGoToAbsolute, nPageNumber)
        objPageRange.InsertBreak WdBreakType.wdPageBreak
      Next nPageNumber

      Selection.HomeKey Unit:=wdStory

      Application.ScreenUpdating = True
    End Sub

       Any help would be so awesome since I have been spending too many hours trying to figure this out. 


    • Edited by JTS1965 Tuesday, September 10, 2019 3:40 PM
    Tuesday, September 10, 2019 3:01 PM

All replies

  • Assuming your code works how you want for the page breaks, at its simplest, i.e. assuming you are starting with no page breaks, no following paragraphs and no "Documents/Return to Narrative" texts, you can include the following two lines after your

    objPageRange.InsertBreak WdBreakType.wdPageBreak


    objPageRange.InsertAfter "Documents/Return to Narrative"

    Otherwise, I think you will need at least to describe what your existing macro is doing wrong.

    Peter Jamieson

    Thursday, September 12, 2019 10:11 AM