2016-11-02 4 views
0

私は単純な縦向きから横向きに変更するExcelマクロ(下記)を持っています。 Excelの "レコードマクロ"ツールを使用しましたが、このマクロを使用するとコマンドを無視します。他に誰がこれを見たことがありますか?そして、良い解決策はありますか?あなたはこの全体から必要なだけの行が記録されたマクロExcel VBA PageSetupの変更を無視する

Sub Writedown_Format_Landscape() 
' 
' Writedown_Format_Landscape Macro 
Range("A1").Select 

Application.PrintCommunication = False 
With ActiveSheet.PageSetup 
    .PrintTitleRows = "$1:$1" 
    .PrintTitleColumns = "" 
End With 

Application.PrintCommunication = True 
ActiveSheet.PageSetup.PrintArea = "" 
Application.PrintCommunication = False 

With ActiveSheet.PageSetup 
    .LeftHeader = "&D - &T" 
    .CenterHeader = "&F" 
    .RightHeader = "&P/&N" 
    .LeftFooter = "" 
    .CenterFooter = "" 
    .RightFooter = "" 
    .LeftMargin = Application.InchesToPoints(0.25) 
    .RightMargin = Application.InchesToPoints(0.25) 
    .TopMargin = Application.InchesToPoints(0.5) 
    .BottomMargin = Application.InchesToPoints(0.25) 
    .HeaderMargin = Application.InchesToPoints(0.25) 
    .FooterMargin = Application.InchesToPoints(0.25) 
    .PrintHeadings = False 
    .PrintGridlines = True 
    .PrintComments = xlPrintNoComments 
    .CenterHorizontally = True 
    .CenterVertically = False 
    .Orientation = xlLandscape 
    .Draft = False 
    .PaperSize = xlPaperLetter 
    .FirstPageNumber = xlAutomatic 
    .Order = xlDownThenOver 
    .BlackAndWhite = False 
    .Zoom = 100 
End With 

Range("A1").Select 

End Sub 

答えて

0

は次のとおりです。

ActiveSheet.PageSetup.Orientation = xlLandscape 

ちょうどあなたが正しいシートと対話していることを確認するために、シートの参照を変更してください。

Sheets("YourSheetName").PageSetup.Orientation = xlLandscape 

変更がなければ、もう一度印刷プレビューを確認してください。

関連する問題