X
XmlAdoNewbie
Hi All
I have a question regarding word headers and footers. I have a
document that is dynamically created and I need a header on certain
pages of the document i.e) if the document is 20 pages long I will
need the header on pages 15-17. I have 2 sections in my document and I
am pretty sure the pages I want headers on are a separate section from
the rest of the document however when I execute the code the header
appears on all the pages. Any idea how to do this?? Here is the code I
use.
Set myrange = ActiveDocument.Range(Start:=endPageNo, End:=pageNo)
ActiveDocument.Sections.Add Range:=myrange
h = myrange.Information(wdActiveEndSectionNumber)
For Each oSection In ActiveDocument.Sections
Debug.Print oSection.Index
If oSection.Index = h Then
oSection.PageSetup.DifferentFirstPageHeaderFooter = True
oSection.Headers(wdHeaderFooterPrimary).Range.Text = "Test"
End If
Next
Regards,
Erin
I have a question regarding word headers and footers. I have a
document that is dynamically created and I need a header on certain
pages of the document i.e) if the document is 20 pages long I will
need the header on pages 15-17. I have 2 sections in my document and I
am pretty sure the pages I want headers on are a separate section from
the rest of the document however when I execute the code the header
appears on all the pages. Any idea how to do this?? Here is the code I
use.
Set myrange = ActiveDocument.Range(Start:=endPageNo, End:=pageNo)
ActiveDocument.Sections.Add Range:=myrange
h = myrange.Information(wdActiveEndSectionNumber)
For Each oSection In ActiveDocument.Sections
Debug.Print oSection.Index
If oSection.Index = h Then
oSection.PageSetup.DifferentFirstPageHeaderFooter = True
oSection.Headers(wdHeaderFooterPrimary).Range.Text = "Test"
End If
Next
Regards,
Erin