Add new section: Landscape

S

Scott A

I am adding a macro to the toolbar of a document template
that will insert a new section, and set the page layout to
landscape.

Here's where I could use some guidance: I am able to
insert the section, but would like to 'automatically'
reformat the headers and footers so that they are
justified to the right and left of the landscape section.
Right now, they keep the same dimentions of the previous
portrait section.

Is a macro the way to go? I tried copying the section and
creating an autotext entry, but it won't reformat the page
layout...

Any suggestions?

Thanks,

Scott
 
M

Margaret Aldis

Hi Scott

The technique I use is to store the section break (which holds the page
format, the header and footer information, and has 'same as previous' unset)
for the landscape section in an AutoText. The logic of the macro is then:

1. Insert the section break at the current cursor postion (to protect the
current layout)

2 Unset 'same as previous' on all header and footers in the new section
(will be the section following the landscape section)

3 Inset the AutoText

There's more detail in:

http://www.syntagma.demon.co.uk/Articles/WordWorkaround2.pdf

There is also useful information in the first part of

http://www.mvps.org/word/FAQs/Formatting/LandscapeSection.htm

(the later part deals with putting a portrait-oriented number on the
landscape page, which you don't need).
 
S

Scott A

Margaret - Thanks a million. That is exactly the
instruction I was looking for.

Scott
 
S

Scott A

Hmmm...

I've created a new macro that:
1. Inserts a section break at the cursor
2. removes links to previous for headers and footers (I
even swapped out the VBA to use the code in your article)
3. Insert autotext containing the new landscape section,
including the section break......

It works just fine when I follow these steps manually, but
when recording these steps and saving them as a macro, I
get a strange result: the paragraph styles in the footer
of the new section change from their previously defined
styles to new ones (doesn't happen when I just insert the
autotext - only when running the macro).

Here's the code from the macro - maybe there is something
I should change to make it work better? (or do I just re-
record and cross my fingers?)


Sub LandscapeSectionInsert()
'
' LandscapeSectionInsert Macro
' Macro recorded 12.11.2003 by scott.adams
'
Selection.InsertBreak Type:=wdSectionBreakNextPage
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or
ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView =
wdSeekCurrentPageHeader
Selection.HeaderFooter.LinkToPrevious = Not
Selection.HeaderFooter. _
LinkToPrevious
If Selection.HeaderFooter.IsHeader = True Then
ActiveWindow.ActivePane.View.SeekView =
wdSeekCurrentPageFooter
Else
ActiveWindow.ActivePane.View.SeekView =
wdSeekCurrentPageHeader
End If
'Remove running headers and footers
Dim aRunner As HeaderFooter
With Selection.Sections(1)
For Each aRunner In .Footers
aRunner.LinkToPrevious = False
Next aRunner
For Each aRunner In .Headers
aRunner.LinkToPrevious = False
Next aRunner
End With

ActiveWindow.ActivePane.View.SeekView =
wdSeekMainDocument
NormalTemplate.AutoTextEntries
("LandscapeSectionInsert").Insert Where:= _
Selection.Range
End Sub
 
M

Margaret Aldis

Hi Scott

Well, you don't need the recorded code for going into the header and footer
view, because the VBA code from my article will do the job without changing
views. But I don't think that is anything to do with problem - I think it is
to do with the AutoText. Assuming you have stored a section break for a
section where the styles were correct, and they are correct in the target
document, I think you probably just need to add the RichText:=True parameter
(I'm surprised this wasn't in the recorded code).

For comparison my code is:

' Insert the protective break
Selection.InsertBreak Type:=wdSectionBreakNextPage
' Remove the 'Save as Previous' in section headers and footers
Dim aRunner As HeaderFooter
With Selection.Sections(1)
For Each aRunner In .Footers
aRunner.LinkToPrevious = False
Next aRunner
For Each aRunner In .Headers
aRunner.LinkToPrevious = False
Next aRunner
' Insert the landscape section break AutoText
ActiveDocument.AttachedTemplate.AutoTextEntries( _
"landscapebreak").Insert Where:=Selection.Range, RichText:=True
 
S

Scott A

That was fantastic, and fixed the problem.

I'm wondering if I can make a small modification to it to
accomodate another user requirement.

It is possible that the writer needs to end the document
in Landscape layout (the most common application of this
formatting is to insert graphs, slides, and such at the
end of a report).

Because the macro inserts a protective section break for
the landscape section, and yet does not modify the final
invisible section break, I get at least one portrait page
at the end of the document...

Is there a way I can modify the macro to remedy this, and
do this as a reformatting of the final section instead of
an insert? Or is there another approach that is better?

I would love to hear your suggestions!

Thanks,

Scott
 
M

Margaret Aldis

Hi Scott

Have a look at

http://www.mvps.org/word/FAQs/Formatting/WorkWithSections.htm

which gives a way of manually removing the last unwanted (wrongly formatted)
section. Maybe just showing your users how to do this will be sufficient, or
you can try converting it into a macro.

It will be difficult to combine the two cases in one macro without asking
the user what they are trying to do (think Word AutoFormat - you don't want
to be doing what you *think* user's want,now, do you? <g>)

Hope this is some help.
 

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