View Single Post
 
Old 01-20-2020, 01:29 PM
gmaxey gmaxey is offline Windows 10 Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Something like this:
Code:
Sub CreatePageRefs()

    Application.ScreenUpdating = False
    Dim rng As Word.Range, Sec As Word.Section, ft As Word.HeaderFooter, i As Long
    
    Set Sec = ActiveDocument.Sections(1) 'The first section, in Roman (i, ii, iii)
    Set ft = Sec.Footers(wdHeaderFooterPrimary)
    Set rng = ft.Range
    With ft.PageNumbers
        .NumberStyle = wdPageNumberStyleLowercaseRoman
        .RestartNumberingAtSection = True
        .StartingNumber = 1
        .ShowFirstPageNumber = False
    End With
    'rng.Style = wdStyleFooter
    rng.ParagraphFormat.Alignment = wdAlignParagraphCenter
    rng.Collapse wdCollapseEnd
    'rng.Fields.Add Range:=rng, Type:=wdFieldPage
    
    Set Sec = ActiveDocument.Sections(2) 'The second section,
                                                             'switch to Arabic numbering (1,2,3)
    Set ft = Sec.Footers(wdHeaderFooterPrimary)
    Set rng = ft.Range
    ft.LinkToPrevious = False
    With ft.PageNumbers
        .NumberStyle = wdPageNumberStyleArabic
        .RestartNumberingAtSection = True
        .StartingNumber = 1
        .ShowFirstPageNumber = False
    End With
    
    Dim numOfSections As Integer
    numOfSections = ActiveDocument.Sections.Count
    
    For i = 3 To numOfSections 'All remaining sections
                                             ' -- restart so that first page number set to "False"
    Set Sec = ActiveDocument.Sections(i)
        Set ft = Sec.Footers(wdHeaderFooterPrimary)
       ft.LinkToPrevious = False
       Set rng = ft.Range
        With ft.PageNumbers
            .NumberStyle = wdPageNumberStyleArabic
            .RestartNumberingAtSection = True
            .StartingNumber = 1
            .ShowFirstPageNumber = False
        End With
    Next

End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote