Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Long Documents / November 2003

Tip: Looking for answers? Try searching our database.

Add new section: Landscape

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Scott A - 12 Nov 2003 11:12 GMT
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
Margaret Aldis - 12 Nov 2003 11:26 GMT
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).
Signature

Margaret Aldis - Microsoft Word MVP
Syntagma partnership site: http://www.syntagma.co.uk
Word MVP FAQ site: http://www.mvps.org/word

> I am adding a macro to the toolbar of a document template
> that will insert a new section, and set the page layout to
[quoted text clipped - 16 lines]
>
> Scott
Scott A - 12 Nov 2003 12:31 GMT
Margaret - Thanks a million.  That is exactly the
instruction I was looking for.  

Scott
>-----Original Message-----
>Hi Scott
[quoted text clipped - 12 lines]
>
>There's more detail in:

http://www.syntagma.demon.co.uk/Articles/WordWorkaround2.pd
f

>There is also useful information in the first part of
>
[quoted text clipped - 24 lines]
>
>.
Scott A - 12 Nov 2003 14:24 GMT
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
>-----Original Message-----
>Hi Scott
[quoted text clipped - 12 lines]
>
>There's more detail in:

http://www.syntagma.demon.co.uk/Articles/WordWorkaround2.pd
f

>There is also useful information in the first part of
>
[quoted text clipped - 24 lines]
>
>.
Margaret Aldis - 12 Nov 2003 15:19 GMT
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

> Hmmm...
>
[quoted text clipped - 119 lines]
> >
> >.
Scott A - 13 Nov 2003 10:34 GMT
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
>-----Original Message-----
>Hi Scott
[quoted text clipped - 108 lines]
>> >
>> >There's more detail in:

http://www.syntagma.demon.co.uk/Articles/WordWorkaround2.pd
>> f
>> >
[quoted text clipped - 35 lines]
>
>.
Margaret Aldis - 13 Nov 2003 11:53 GMT
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.

Signature

Margaret Aldis - Microsoft Word MVP
Syntagma partnership site: http://www.syntagma.co.uk
Word MVP FAQ site: http://www.mvps.org/word

> That was fantastic, and fixed the problem.
>
[quoted text clipped - 199 lines]
> >
> >.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.