Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

inserting footer to first page of inserted file but not of doc

Status
Not open for further replies.

lemonhalls

Technical User
Jun 11, 2004
52
CA
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
 
Hi,

Separate each section with...

Section Breaks

Then control the header/footer with the Same as Previous property.

Skip,

Want to get great answers to your Tek-Tips questions? Have a look at faq222-2244
 
I thought this line of code in insertFile does seperate each section with a section break and sets the footer to be the same as previous...

Selection.InsertBreak Type:=wdSectionBreakNextPage
ActiveDocument.Sections(1).PageSetup.DifferentFirstPageHeaderFooter = False
_______________________

I tested it in insertFooter code anyway by changing

ActiveDocument.Sections _
(1).PageSetup.DifferentFirstPageHeaderFooter = True
With ActiveDocument.Sections(1)

to false, and got the same result as true. In both cases, only the TOC and the first page of the inserted files did not get a page number footer.

other suggestions?
 
What IS happening and what to you WANT to happen? (It's not clear to me)

Skip,

Want to get great answers to your Tek-Tips questions? Have a look at faq222-2244
 
what is happening:
page number footer is on every page except on the TOC page and on the first page of each inserted file

what I would like to happen:
page number footer on every page except cover page and TOC page.

background:
these sections are seperated by a section break (next page), ie cover, section break (sb), TOC, sb, inserted file 1 (if), sb, if2, sb, if3 etc
 
The footer of the inserted file should NOT be same as previous. Should have designated that Page Numbering starts.

Skip,

Want to get great answers to your Tek-Tips questions? Have a look at faq222-2244
 
thanks for the advice.

I followed your instructions, now the state:
page numbers on every page except cover, TOC and first of inserted page.

what I did:
I changed the following from false to true
Selection.InsertBreak Type:=wdSectionBreakNextPage
ActiveDocument.Sections(1).PageSetup.DifferentFirstPageHeaderFooter = True


and inserted a add page number code to the following
For i = 1 To .FoundFiles.Count
Selection.TypeParagraph
Selection.InsertFile FileName:=.FoundFiles(i), Range:="", _
ConfirmConversions:=False, Link:=False, Attachment:=False

Selection.Find.ClearFormatting
With Selection.Find
.Text = "Printer Friendly Version"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute
Selection.HomeKey Unit:=wdLine
Selection.MoveDown Unit:=wdLine, Count:=4, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1

Selection.InsertBreak Type:=wdSectionBreakNextPage
ActiveDocument.Sections(1).PageSetup.DifferentFirstPageHeaderFooter = True

With ActiveDocument.Sections(1)
.Footers(wdHeaderFooterPrimary).PageNumbers.Add _
PageNumberAlignment:=wdAlignPageNumberRight, _
FirstPage:=False
End With

margin
Next i
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top