How to determine Odd and Even page programmatically

A

aushknotes

Hi,

I am using Word 2003 & I have documents that need to be mirror-printed with
different footers in odd and even pages (i.e. one footer for odd page footers
& anther for even page footers). Would you kindly inform how I go to the odd
page footer story and the even page footer story so that I can customise
these two different footers? Could they be in the stories collection?

Many thanks,
 
J

Jay Freedman

Hi,

I am using Word 2003 & I have documents that need to be mirror-printed with
different footers in odd and even pages (i.e. one footer for odd page footers
& anther for even page footers). Would you kindly inform how I go to the odd
page footer story and the even page footer story so that I can customise
these two different footers? Could they be in the stories collection?

Many thanks,

Usually instead of manipulating footers through macro code, it's much better to
start with a template whose footers have already been set up with the necessary
text and fields.

If you must use code, though, you access them like this:

ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary) _
.Range.Text = _
"inside margin" & vbTab & vbTab & "outside margin"
ActiveDocument.Sections(1).Footers(wdHeaderFooterEvenPages) _
.Range.Text = _
"outside margin" & vbTab & vbTab & "inside margin"

If there are multiple sections, you can run a "For Each mySection in
ActiveDocument.Sections" loop. If you also need to insert fields in the footer,
assign the footer's range to a Range object that you collapse to the proper
location and then use in an ActiveDocument.Fields.Add statement.
 
A

aushknotes

Thanks very much for your help.


Jay Freedman said:
Usually instead of manipulating footers through macro code, it's much better to
start with a template whose footers have already been set up with the necessary
text and fields.

If you must use code, though, you access them like this:

ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary) _
.Range.Text = _
"inside margin" & vbTab & vbTab & "outside margin"
ActiveDocument.Sections(1).Footers(wdHeaderFooterEvenPages) _
.Range.Text = _
"outside margin" & vbTab & vbTab & "inside margin"

If there are multiple sections, you can run a "For Each mySection in
ActiveDocument.Sections" loop. If you also need to insert fields in the footer,
assign the footer's range to a Range object that you collapse to the proper
location and then use in an ActiveDocument.Fields.Add statement.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top