2015-04-05 95 views
0

我寫了一個Word 2007宏來設置頁面並更改方向。除了將文檔從縱向更改爲橫向之外,所有設置都起作用。 (您可以在代碼中看到下面我設置了兩遍。)Word 2007 VBA頁面方向風景不起作用

With Selection.PageSetup 
    .LineNumbering.Active = False 
    .Orientation = wdOrientLandscape 
    .TopMargin = InchesToPoints(0.8) 
    .BottomMargin = InchesToPoints(0.7) 
    .LeftMargin = InchesToPoints(0.5) 
    .RightMargin = InchesToPoints(0.5) 
    .Gutter = InchesToPoints(0) 
    .HeaderDistance = InchesToPoints(0.5) 
    .FooterDistance = InchesToPoints(0.6) 
    .PageWidth = InchesToPoints(8.5) 
    .PageHeight = InchesToPoints(11) 
    .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 
End With 


ActiveDocument.PageSetup.Orientation = wdOrientLandscape 

我的代碼後,我進入一個表,並做更多的格式 - 但僅限於表。

任何想法?

+0

在'.Orientation'語句中放置了斷點。使用F8查看你的宏,通過這些語句。你是否觀察到文檔方向改變(如預期)? – 2015-04-05 18:52:39

回答

0

如果您正在編輯多頁文檔,您可能需要確保您嘗試格式化的頁面全部位於一個區段中。 您是否曾嘗試在正在處理的頁面前後放置分節符,然後嘗試設置方向?