landscape page/s into portrait doc, different odd/even header/foot

I

IndianSummer

Hi,
I am trying to automate the insertion of a landscape page into a portrait
document - in ver 2003. So far i have successfully created a macro that
completes the steps as outlined at the MVPs' site -
http://word.mvps.org/faqs/formatting/LandscapeSection.htm. Thanks heaps Bill,
Suzanne and Dave.

My issue now is that the document has different odd/even page
headers/footers - I need help getting those settings right in the macro.

At the moment, my macro does turn off "same as previous" in both header and
footer, and adjusts them to the wider page width for the FIRST landscape page
(which will be either odd or even depending on where the user was when they
inserted the landscape page).

But when the user inserts enough text or graphics that the landscape section
runs over more than one page, the header and footer on the second page, which
will be either even or odd, depending.., kicks in set to "same as previous"
and shows with the portrait page settings.

Can anyone advise the best approach? Do I have to make my macro insert a
page break in the new landscape section, so I can attack the header/footer
settings for both odd and even pages? If so, how does my macro then find the
right page break to delete it again? I need the end result to be a single
landscape page, but with both odd and even header/footers to work, in case...

Any suggestions gratefully received, thanks in advance. And happy new year
to all :)

regards,
Helen
 
J

Jay Freedman

Hi Helen,

No, with VBA you don't have to create a temporary page to unlink the
other pages' headers and footers. That's needed only when doing the
job manually.

In your code, use statements like these:

With ActiveDocument.Sections(2)
.Headers(wdHeaderFooterPrimary).LinkToPrevious = False
.Footers(wdHeaderFooterPrimary).LinkToPrevious = False
.Headers(wdHeaderFooterEvenPages).LinkToPrevious = False
.Footers(wdHeaderFooterEvenPages).LinkToPrevious = False
End With

If the landscape section is something other than Section 2, use that
number; or, better, assign the correct section to a variable that you
declare as a Section object:

Dim mySection As Section
Set mySection = ActiveDocument.Sections(2) ' or whatever

and then use that variable in the 'With' statement above.

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

Jay Freedman

In case it isn't obvious, you need to do the same to the portrait
section that follow the landscape section...
 
D

Doug Robbins - Word MVP

In each Section of a document, there are a number of headers and footers,
each of which can be accessed via code whether or not the necessary pages
are in the Section.

Dim asection As Section
Set asection = Selection.Sections(1)
With asection
With .PageSetup
.DifferentFirstPageHeaderFooter = True
.OddAndEvenPagesHeaderFooter = True
End With
.Footers(wdHeaderFooterFirstPage).Range.Text = "Text for first page of
section footer"
.Footers(wdHeaderFooterEvenPages).Range.Text = "Text for even numbered
pages of section footer"
.Footers(wdHeaderFooterPrimary).Range.Text = "Text for odd numbered
pages of section footer"
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
I

IndianSummer

Hi Jay, many thanks for your reply I really appreciate it. Your suggestion
works a treat in overcoming the key issue I asked about.

I now have two related questions if you or someone has time...

1. In my newly inserted landscape section, I need both the odd and even page
header/footers to have a right aligned tab stop at the right margin.

At the moment my code (via the recorder) does this in the first page of the
new section:
....
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.ParagraphFormat.TabStops.ClearAll
Selection.ParagraphFormat.TabStops.Add Position:=CentimetersToPoints(24.81 _
), Alignment:=wdAlignTabRight, Leader:=wdTabLeaderSpaces

...etc. same thing for the footer.

Needless to say I can't use this approach in the other (either odd or even)
page that doesn't exist in the section yet. Any suggestions please?

2. At this point i don't need to know the item number of the section I'm
working in, so i've used Doug's suggestion (his post below) to work on the
current active section whatever it may be.

ie. Dim mySection as section
Set mySection = Selection.Sections(1)

But I can see that it would be really helpful to be able to retrieve and
utilise the item number of whatever section the user has clicked in. How
would i extract that info? – I’ve had a tinker and can’t work it out..

Thanks again Jay and best regards,
Helen
 
D

Doug Robbins - Word MVP

Selection.Sections(1) will always be the Section in which the user has
clicked in.

Once again, the page does not have to exist to (pre-)setup the tabs in the
headers or footers that will appear on that page when/if it comes into
being:

With Selection.Sections(1)
.PageSetup.OddAndEvenPagesHeaderFooter = True
.Footers(wdHeaderFooterEvenPages).Range.Paragraphs(1).TabStops.Add
Position:=CentimetersToPoints(24.81), _
Alignment:=wdAlignTabRight, Leader:=wdTabLeaderSpaces
End With

Also, it is not necessary to go into the header pane using
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
--
Hope this helps,

Doug Robbins - Word MVP

Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.
 
I

IndianSummer

Hi Doug,

Many thanks for your response! I have combined the help you and Jay offered
to resolve my issues with the "same as previous" setting.

I have posted a couple of follow-up questions in my reply to Jay above,
hoping someone can please help me some more :) ?

My thanks again.
Helen
 
I

IndianSummer

Ah great, thanks so much Doug! I did have a good look at the range object
but just couldn't figure it out....would never have got it on my own.

I really appreciate the help.
best regards,
Helen
 

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