#1
|
|||
|
|||
Change Page size
Hello!
I have used the macro recorder to change the page size of a document to A4 but I got the largest code ever to do this simple change. Is there any way to change page without the need of including such large lines of code? This is what I got from the macro recorder: Sub Macro1() ' ' Macro1 Macro ' ' With Selection.PageSetup .LineNumbering.Active = False .Orientation = wdOrientPortrait .TopMargin = CentimetersToPoints(2.5) .BottomMargin = CentimetersToPoints(2.5) .LeftMargin = CentimetersToPoints(3) .RightMargin = CentimetersToPoints(3) .Gutter = CentimetersToPoints(0) .HeaderDistance = CentimetersToPoints(1.25) .FooterDistance = CentimetersToPoints(1.25) .PageWidth = CentimetersToPoints(21) .PageHeight = CentimetersToPoints(29.7) .FirstPageTray = wdPrinterDefaultBin .OtherPagesTray = wdPrinterDefaultBin .SectionStart = wdSectionNewPage .OddAndEvenPagesHeaderFooter = False .DifferentFirstPageHeaderFooter = False .VerticalAlignment = wdAlignVerticalTop .SuppressEndnotes = False .MirrorMargins = False .TwoPagesOnOne = False .BookFoldPrinting = False .BookFoldRevPrinting = False .BookFoldPrintingSheets = 1 .GutterPos = wdGutterPosLeft .SectionDirection = wdSectionDirectionLtr .LayoutMode = wdLayoutModeDefault End With End Sub |
#2
|
||||
|
||||
The relevant lines from your code is:
Code:
Sub Macro1() With Selection.PageSetup .PageWidth = CentimetersToPoints(21) .PageHeight = CentimetersToPoints(29.7) End With End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
||||
|
||||
Simpler:
Code:
Sub Demo() Selection.PageSetup.PaperSize = wdPaperA4 End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#4
|
|||
|
|||
Thanks Guessed. Thatīs exactly what I was looking for
|
#5
|
||||
|
||||
If you wanted to use Paul's simpler option, you may also need to include an orientation line to specify either Portrait or landscape layout
Selection.PageSetup.Orientation = wdOrientPortrait
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Custom page size - Page color not covering entire page when converting to PDF | icor1031 | Word | 9 | 12-09-2019 08:21 PM |
Change page size reducing both margins | WizardDani | Word | 1 | 01-04-2018 06:41 AM |
Configured page size to 20 inches height : why the page still breaks @ the default 9,6 ? | Ron Wolpa | Word | 4 | 08-18-2016 06:43 PM |
Change Default Zoom Size to 'Page Width' | tyger330 | Word | 9 | 12-19-2012 07:50 AM |
how change size font to inches size | kkepo | Word | 4 | 08-28-2012 08:53 PM |