Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 01-10-2018, 09:45 AM
slaycock slaycock is offline numbering after section change Windows 7 64bit numbering after section change Office 2016
Expert
 
Join Date: Sep 2013
Posts: 255
slaycock is on a distinguished road
Default

There must be more code that that because what you supplied won't run on its own.

You also need to be a little clearer regarding where the section breaks are located.

Do you insert a section break before you insert a document?

When you insert text from another document the cursor ends up at the end of the inserted text so if you want to set page numbering of the section at the start of the inserted text to 1 you will need to save the location of the cursor before you insert the file. You may also find that you don't actually get page 1 where you think it should go if the text before the section break is too long.

The code below demonstrates how to change the page number of the section where the file is inserted to 1(ish - due to the caveats above).

If the file starts with a section break then the code below will need to be modified to move the insertion point into the first section of the inserted text.

Code:
Sub test()
Dim insertion_point_before_insertion As Word.range

    Set insertion_point_before_insertion = Selection.range.Duplicate
    Selection.InsertFile FileName:="test.docx", range:="", ConfirmConversions:=True, Link:=False, Attachment:=False
    
    insertion_point_before_insertion.Select
    With Selection.HeaderFooter.PageNumbers
        .StartingNumber = 1
        .RestartNumberingAtSection = True
    End With

End Sub
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
numbering after section change Page-numbering question: continue numbering from one section to the next? {PAGE} of {SECTIONPAGES} SDwriter Word 12 10-25-2017 06:56 AM
numbering after section change Section numbering screwed up scorpio_oz Word 7 04-06-2016 06:02 AM
Why does Word indexing change section page numbering to "continuous"? kaspencer Word 6 07-02-2015 02:24 PM
numbering after section change Help with Section Numbering in Table of Contents Virtualkat Word 1 10-03-2012 07:10 AM
Heading numbering and section breaks uby Word 2 11-22-2010 10:03 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:19 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft