lemonhalls
Technical User
Hi,
I have this code to insert the page number/footer to my document.
But this document begins with a cover page, then a TOC is inserted and then followed by files inserted one after another.
Since the first page is set to have a different footer. The first page of every inserted file does not get a page number.
any advice on activating the page number on the first pages of the inserted files only and not the cover page nor TOC?
Thanks!
____________________________________________________
Sub insertFooter()
ActiveDocument.Sections _
(1).PageSetup.DifferentFirstPageHeaderFooter = True
With ActiveDocument.Sections(1)
.Footers(wdHeaderFooterPrimary).PageNumbers.Add _
PageNumberAlignment:=wdAlignPageNumberRight, _
FirstPage:=False
End With
End Sub
_______________________________________________________
'part of the insert file code
'move to the end of the document to insert files
Selection.EndKey Unit:=wdStory, Extend:=wdMove
With Application.FileSearch
.NewSearch
.LookIn = activeDir
.SearchSubFolders = False
.FileName = "*.doc"
.MatchTextExactly = False
'retrieves the files in alphabetical order
If .Execute(SortBy:=msoSortByFileName, _
sortOrder:=msoSortOrderAscending) > 0 Then
For i = 1 To .FoundFiles.Count
Selection.TypeParagraph
Selection.InsertFile FileName:=.FoundFiles(i), Range:="", _
ConfirmConversions:=False, Link:=False, Attachment:=False
Selection.InsertBreak Type:=wdSectionBreakNextPage
ActiveDocument.Sections(1).PageSetup.DifferentFirstPageHeaderFooter = False
margin
Next i
I have this code to insert the page number/footer to my document.
But this document begins with a cover page, then a TOC is inserted and then followed by files inserted one after another.
Since the first page is set to have a different footer. The first page of every inserted file does not get a page number.
any advice on activating the page number on the first pages of the inserted files only and not the cover page nor TOC?
Thanks!
____________________________________________________
Sub insertFooter()
ActiveDocument.Sections _
(1).PageSetup.DifferentFirstPageHeaderFooter = True
With ActiveDocument.Sections(1)
.Footers(wdHeaderFooterPrimary).PageNumbers.Add _
PageNumberAlignment:=wdAlignPageNumberRight, _
FirstPage:=False
End With
End Sub
_______________________________________________________
'part of the insert file code
'move to the end of the document to insert files
Selection.EndKey Unit:=wdStory, Extend:=wdMove
With Application.FileSearch
.NewSearch
.LookIn = activeDir
.SearchSubFolders = False
.FileName = "*.doc"
.MatchTextExactly = False
'retrieves the files in alphabetical order
If .Execute(SortBy:=msoSortByFileName, _
sortOrder:=msoSortOrderAscending) > 0 Then
For i = 1 To .FoundFiles.Count
Selection.TypeParagraph
Selection.InsertFile FileName:=.FoundFiles(i), Range:="", _
ConfirmConversions:=False, Link:=False, Attachment:=False
Selection.InsertBreak Type:=wdSectionBreakNextPage
ActiveDocument.Sections(1).PageSetup.DifferentFirstPageHeaderFooter = False
margin
Next i