#1
|
|||
|
|||
Macro to insert Landscape page
Hi All,
I have a macro - InsertLandscape, which inserts a landscape page wherever the cursor is on a document. The problem with this macro is that if I try to insert a landscape page right after a portrait page...my margins and headers reflect those of the portrait page. How do I modify my macro to correctly align the margins and headers to fit on the landscape page? Below is my macro: Code:
sub InsertLandscape On Error Resume Next ' Add Section Break Next Page Selection.InsertBreak Type:=wdSectionBreakNextPage If Selection.PageSetup.Orientation = wdOrientPortrait Then Selection.PageSetup.Orientation = wdOrientLandscape Else Selection.PageSetup.Orientation = wdOrientPortrait End If With Selection.PageSetup .LineNumbering.Active = False .Orientation = wdOrientLandscape .TopMargin = CentimetersToPoints(1) .BottomMargin = CentimetersToPoints(1) .LeftMargin = CentimetersToPoints(1.5) .RightMargin = CentimetersToPoints(1.5) .Gutter = CentimetersToPoints(0) .HeaderDistance = CentimetersToPoints(4) .FooterDistance = CentimetersToPoints(0.6) .PageWidth = CentimetersToPoints(29.7) .PageHeight = CentimetersToPoints(21) .FirstPageTray = wdPrinterDefaultBin .OtherPagesTray = wdPrinterDefaultBin .SectionStart = wdSectionNewPage .OddAndEvenPagesHeaderFooter = False '.DifferentFirstPageHeaderFooter = False .DifferentFirstPageHeaderFooter = True .VerticalAlignment = wdAlignVerticalTop .SuppressEndnotes = False .MirrorMargins = False .TwoPagesOnOne = False .BookFoldPrinting = False .BookFoldRevPrinting = False .BookFoldPrintingSheets = 1 .GutterPos = wdGutterPosLeft End With Selection.InsertBreak Type:=wdSectionBreakNextPage ' Unlink To Previous footer Dim myRng As Word.Range Set oDoc = ActiveDocument ' Get the index number of the added section i = oDoc.Range(0, Selection.Sections(1).Range.End).Sections.Count With oDoc.Sections(i) For j = 1 To 3 .Headers(j).LinkToPrevious = False .Footers(j).LinkToPrevious = False Next j End With ' Note: j provides the constant value to unlink all three header\footer types lbl_Exit: ' Continue page numbering ' With Selection.Sections(1).Headers(1).PageNumbers .NumberStyle = wdPageNumberStyleArabic .HeadingLevelForChapter = 0 .IncludeChapterNumber = False .ChapterPageSeparator = wdSeparatorHyphen .RestartNumberingAtSection = False .StartingNumber = 0 End With Exit Sub End Sub |
#2
|
||||
|
||||
You need to change your macro to set the left, right, top, bottom & gutter margins to whatever you require for a landscape page. In this case, I suspect it's just a matter of swapping the CentimetersToPoints(1) and CentimetersToPoints(1.5) settings.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Landscape Orientation - Rotate page so top of landscape is printed on left side | swifty2010 | Word | 17 | 06-11-2022 05:50 PM |
Macro to open the Insert>Cover Page window /dialog box | Catty | Word VBA | 3 | 02-24-2014 06:02 PM |
Prints in half page landscape | lostsoul62 | Excel | 2 | 07-22-2013 01:24 PM |
Macro to insert new page... | samanthaj | Word | 17 | 01-31-2012 01:53 PM |
Word 97, Landscape page orientation issue | RodA | Word | 2 | 03-07-2011 04:51 PM |