title: Changing the orientation (portrait or landscape) of an Excel chart using VBA
body: <p>I am trying to write a macro to automatically print all the charts I have created in a workbook using another macro. (literally hundreds) The problem I'm having is that I cannot figure out how to change the graph from a portrait layout to a landscape layout using VBA. I was wondering if anyone could help me out. I tried the code bellow but it gives me an error at the line " .ChartObjects(x).PageSetup.Orientation = xlLandscape " I understand that for a chart object that this isn't the correct property but I can't figure out what else it is.</p>
  
  <p>Any help would be appreciated! </p>
  
  <pre><code>Option Explicit
  
  Sub Print_All_Charts()
      Dim szASheet As String
      szASheet = ActiveSheet.Name
  
      Dim lChartObjCount As Long
      lChartObjCount = ActiveSheet.ChartObjects.Count
  
      With Application
          .ScreenUpdating = False
  
          .ActivePrinter = "HP Color LaserJet 5550 PS on Ne08:"
  
          'On Error Resume Next
          Dim wks As Worksheet
          For Each wks In ActiveWorkbook.Worksheets
  
              Dim x As Long
              For x = 1 To lChartObjCount
  
                  With wks
  
                      .ChartObjects(x).PageSetup.Orientation = xlLandscape
  
                      .ChartObjects(x).Select
  
                      .ChartObjects(x).Activate
  
                      .PrintOut , , 1
  
                  End With
  
              Next x
  
          Next wks
  
          ActiveChart.Deselect
          With Sheets(szASheet)
              .Select
              .Range("A1").Select
          End With
  
          .ScreenUpdating = True
      End With
  End Sub
  </code></pre>