none
Problem printing sparklines RRS feed

  • Question

  • I need help understanding an issue I am having printing a range containing sparklines.   I simply use the following VBA code to print a range.  Column P contains a sparkline on each row but they do not print.  When I manually print the same range using the File menu they do print.  I must be doing something wrong.

    With ThisWorkbook.Sheets("WatchlistReport")
        lastrow = .Range("A2:A500").End(xlDown).Row
        With .PageSetup
            .LeftMargin = Application.InchesToPoints(0.25)
            .RightMargin = Application.InchesToPoints(0.25)
            .Zoom = 60
            .PrintArea = "$A$1:$P$" & lastrow
        End With
        .PrintOut
    End With

    Monday, September 15, 2014 6:32 PM

All replies

  • Hi,

    After testing with your code, I failed to reproduce your issue. If I put the sparklines in the column P, the sparklines will be display in the next page since the width of a page cannot contain all the data of column A to P. Have you check whether the data is display in the next page?

    To test the code, you can replace .PrintOut to .PrintPreview, which will open a print preview window instead of printing out directly. If the print preview result is as you expected, which means your code is OK. If the print preview result is incorrect, I suggest you sharing your sample worksheet through OneDrive to help us troubleshoot and testing in other machines.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, September 16, 2014 5:46 AM
    Moderator
  • I was using a zoom factor of 60 to force the range to print on one page wide.  Column P printed OK but the sparklines did not show.

    I have modified the code as follows and the sparklines still do not print:

    With ThisWorkbook.Sheets("WatchlistReport")
        lastrow = .Range("A2:A500").End(xlDown).Row
        With .PageSetup
            .Orientation = xlLandscape
            .LeftMargin = Application.InchesToPoints(0.25)
            .RightMargin = Application.InchesToPoints(0.25)
            .Zoom = False
            .FitToPagesWide = 1
            .FitToPagesTall = False
            .PrintArea = "$A$1:$P$" & lastrow
        End With
        .PrintOut
        .Protect "24six"
        .Visible = False
    End With

    When I use the File menu to print the range with the same settings, the sparklines do print.

    Tuesday, September 16, 2014 12:36 PM
  • Hi Bob,

    >> When I manually print the same range using the File menu they do print.

    Since you could print the sparklines manually. I think you could consider to record a macro to see whether the auto-generated VBA code will work.

    If this issue still exits by using the auto-generated VBA code. Would you mind sharing your sample workbook through OneDrive to help us reproduce this issue at our side?

    Regards,

    Jeffrey


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, September 17, 2014 7:47 AM
    Moderator