+ Reply to Thread
Results 1 to 11 of 11

Print Macro - Landscape Orientation Graph

Hybrid View

  1. #1
    Registered User
    Join Date
    11-24-2011
    Location
    Mansfield
    MS-Off Ver
    Excel 2003
    Posts
    6

    Print Macro - Landscape Orientation Graph

    Hi. I need to print on a landscape piece of A4 a graph (which also needs to fill the entire page). I already have the basic function down.

    Sub PrintChart()
        Sheet4.PageSetup.Orientation = xlLandscape.ChartObjects("Chart 6").Chart.PrintOut
    End Sub
    For some reason, I get 'Invalid Qualifier'. What is the solution to this?
    Last edited by Oliver Rogers; 11-28-2011 at 07:41 AM. Reason: Problem SOLVED

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Print Macro - Landscape Orientation Graph

    I think that should be 2 lines of code not 1

    Sub PrintChart()
        Sheet4.PageSetup.Orientation = xlLandscape
        Sheet4.ChartObjects("Chart 6").Chart.PrintOut
    End Sub
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    11-24-2011
    Location
    Mansfield
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Print Macro - Landscape Orientation Graph

    The code unfortuantely returns error code 80070057 on line 3 of the following code (runtime error is item specified not found)
    Sub PrintChart()
        Sheet4.PageSetup.Orientation = xlLandscape
        Sheet4.ChartObjects("Chart 6").Chart.PrintOut
    End Sub

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Print Macro - Landscape Orientation Graph

    Do you have a worksheet with the code name Sheet4.
    Does that worksheet contain a chart object called "Chart 6"?

  5. #5
    Registered User
    Join Date
    11-24-2011
    Location
    Mansfield
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Print Macro - Landscape Orientation Graph

    I presume I do have a chart called "Chart 6" as another code I used specifies that the chart which exists in that worksheet is called "Chart 6" and yes, the worksheet does go by the name 'Sheet4'.

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Print Macro - Landscape Orientation Graph

    can you post example file to illustrate the error as my test does not fail.

  7. #7
    Registered User
    Join Date
    11-24-2011
    Location
    Mansfield
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Print Macro - Landscape Orientation Graph

    I can post the actual file if you wish. Sheet4 would be the sheet labelled Graph
    Attached Files Attached Files
    Last edited by Oliver Rogers; 11-28-2011 at 07:19 AM.

  8. #8
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Print Macro - Landscape Orientation Graph

    Your sheet tab maybe called "Graph" but in the code you are using codename syntax. The actual codename is Sheet3.

    Sub PrintChart()
        With Worksheets("Graph")
            .PageSetup.Orientation = xlLandscape
            .ChartObjects("Chart 6").Chart.PrintOut
        End With
    End Sub

  9. #9
    Registered User
    Join Date
    11-24-2011
    Location
    Mansfield
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Print Macro - Landscape Orientation Graph

    Thanks. I've printed a copy however it is still in portrait orientation

  10. #10
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Print Macro - Landscape Orientation Graph

    Try this which sets the layout of the chartobject when printed rather than the sheet which it is located on

    Sub PrintChart()
        With Worksheets("Graph")
            With .ChartObjects("Chart 6").Chart
                .PageSetup.Orientation = xlLandscape
                .PrintOut
            End With
        End With
    End Sub

  11. #11
    Registered User
    Join Date
    11-24-2011
    Location
    Mansfield
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Print Macro - Landscape Orientation Graph

    I noticed that my page layout changes to Portrait when it's on Landscape (being set via the toolbar). Changed it to Portrait and it now prints on landscape, also filling the page. Thank you for your help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1