Letter to A4

S

Scott A

I have a macro that changes the paper size from A4 to
Letter, and updates the TOC. I also have another that
does the reverse.

It works fine, until I insert a Landscape section into the
document, when it indicates that a value is out of range
(highlighting .LineNumbering.Active = False)

Here's the first part of the macro that switches the page
layout:
==========================================================
With ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.TopMargin = CentimetersToPoints(2.5)
.BottomMargin = CentimetersToPoints(2.5)
.LeftMargin = CentimetersToPoints(2.5)
.RightMargin = CentimetersToPoints(2.5)
.Gutter = CentimetersToPoints(0)
.HeaderDistance = CentimetersToPoints(1.5)
.FooterDistance = CentimetersToPoints(1)
.PageWidth = CentimetersToPoints(21.59)
.PageHeight = CentimetersToPoints(27.94)
.FirstPageTray = wdPrinterFormSource
.OtherPagesTray = wdPrinterFormSource
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
.TwoPagesOnOne = False
.GutterPos = wdGutterPosLeft
End With

========================================================

Is there a better way to do this that will work with both
landscape and portrait sections in the document?

Thanks,

Scott A
 
W

Word Heretic

G'day "Scott A" <[email protected]>,

go through every .Sections(k) in the ActiveDocument


I have a macro that changes the paper size from A4 to
Letter, and updates the TOC. I also have another that
does the reverse.

It works fine, until I insert a Landscape section into the
document, when it indicates that a value is out of range
(highlighting .LineNumbering.Active = False)

Here's the first part of the macro that switches the page
layout:
==========================================================
With ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.TopMargin = CentimetersToPoints(2.5)
.BottomMargin = CentimetersToPoints(2.5)
.LeftMargin = CentimetersToPoints(2.5)
.RightMargin = CentimetersToPoints(2.5)
.Gutter = CentimetersToPoints(0)
.HeaderDistance = CentimetersToPoints(1.5)
.FooterDistance = CentimetersToPoints(1)
.PageWidth = CentimetersToPoints(21.59)
.PageHeight = CentimetersToPoints(27.94)
.FirstPageTray = wdPrinterFormSource
.OtherPagesTray = wdPrinterFormSource
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
.TwoPagesOnOne = False
.GutterPos = wdGutterPosLeft
End With

========================================================

Is there a better way to do this that will work with both
landscape and portrait sections in the document?

Thanks,

Scott A

Steve Hudson

Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
wordheretic.com

If my answers r 2 terse, ask again or hassle an MVP,
at least they get recognition for it then.
Lengthy replies offlist require payment.
 
G

Guest

G'Day Steve!

I've tried modifiying the code, but am not very good with
looping structures. How should I modify this?

With ActiveDocument.Sections(1)
For Each aSection In ActiveDocument.PageSetup
.LineNumbering.Active = False
.TopMargin = CentimetersToPoints(2.5)
.BottomMargin = CentimetersToPoints(2.5)
.LeftMargin = CentimetersToPoints(2.5)
.RightMargin = CentimetersToPoints(2.5)
.Gutter = CentimetersToPoints(0)
.HeaderDistance = CentimetersToPoints(1.5)
.FooterDistance = CentimetersToPoints(1)
.PageWidth = CentimetersToPoints(21.59)
.PageHeight = CentimetersToPoints(27.94)
.FirstPageTray = wdPrinterFormSource
.OtherPagesTray = wdPrinterFormSource
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = True
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
.TwoPagesOnOne = False
.GutterPos = wdGutterPosLeft
Next aSection

End With
 
J

Jonathan West

Hi Scott

You haven't quite got the syntax right

The first 2 lines should be like this

For Each aSection In ActiveDocument.PageSetup
With aSection

The last 2 lines should be like this

End With
Next aSection
 

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