Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Change orientation

  Asked By: Meenachi    Date: Dec 07    Category: MS Office    Views: 574
  

Does anybody know how to change the orientation from landscape/
portrait or vice versa - i am trying to print different ranges in a
worksheet and have to change the orientation - have three differnet
ranges assigned to command buttons - they work fine but will not
change from portrait/landscape - once the first range prints it will
not change - any ideas? Code below that I have been using

Private Sub CommandButton_Click()
Range("a20").Select
ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
End Sub

Private Sub CommandButton1_Click()
ActiveSheet.PageSetup.PrintArea = "$BS$3:$BY$43"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Orientation = xlPortrait
PaperSize = xlPaperA4
Range("a20").Select
End Sub

Private Sub CommandButton2_Click()
ActiveSheet.PageSetup.PrintArea = "$ce$3:$ck$43"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Range("a20").Select
End Sub

Private Sub CommandButton3_Click()
Range("A10:P43").Select
Orientation = xlLandscape
PaperSize = xlPaperA4
ActiveSheet.PageSetup.PrintArea = "$A$10:$P$43"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Range("a20").Select
End Sub

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Maxine Jones     Answered On: Dec 07

Should Orientation and Papersize not be preceded by a DOT?
.Orientation = xlLandscape, since they refer to the selection defined
just above?

TIP: Setting Print Ranges in VBA is painfully slow on execution. Well
done on keeping yours simple, and not setting borders etc. I racked my
brain a few months ago when I did it the first time!

 
Didn't find what you were looking for? Find more on Change orientation Or get search suggestion and latest updates.




Tagged: