VBA - Print charts

j4ymf

Well-known Member
Joined
Apr 28, 2003
Messages
741
Office Version
  1. 365
Platform
  1. Windows
Hello All

I have come across this code that lets you print the charts with in the sheet. via a button

how do I change and where, so it prints in colour because the default on work printers is black and white and how do I print it landscape not portrait.

thanks Jason

Code:
Sub PrintEmbeddedCharts()
     Dim ChartList As Integer
     Dim X As Integer
     ' Variable chartlist stores a count of all embedded charts.
     ChartList = ActiveSheet.ChartObjects.Count
     ' Increments the counter variable 'X' in a loop.
     For X = 1 To ChartList
         ' Selects the chart object.
         ActiveSheet.ChartObjects(X).Select
         ' Makes chart active.
         ActiveSheet.ChartObjects(X).Activate
         ' Prints one copy of active chart.
         ActiveChart.PrintOut Copies:=1
     Next
End Sub
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Untested code anyways
Rich (BB code):
Sub PrintEmbeddedCharts()
     Dim ChartList As Integer
     Dim X As Integer
     ' Variable chartlist stores a count of all embedded charts.
     ChartList = ActiveSheet.ChartObjects.Count
     ' Increments the counter variable 'X' in a loop.
     For X = 1 To ChartList
         ' Selects the chart object.
         ActiveSheet.ChartObjects(X).Select
         ' Makes chart active.
         ActiveSheet.ChartObjects(X).Activate
         'Set the colour to black and white
         ActiveSheet.ChartObjects(X).PageSetup.BlackAndWhite = ""
         ' Prints one copy of active chart.
         ActiveChart.PrintOut Copies:=1
     Next
End Sub
 
Last edited:
Upvote 0
hi
thank for you help

I get an error saying object doesn't support this method

Jason
 
Upvote 0
or maybe this way
Rich (BB code):
Sub PrintEmbeddedCharts()
     Dim ChartList As Integer
     Dim X As Integer
     ' Variable chartlist stores a count of all embedded charts.
     ChartList = ActiveSheet.ChartObjects.Count
     ' Increments the counter variable 'X' in a loop.
     For X = 1 To ChartList
         ' Selects the chart object.
         ActiveSheet.ChartObjects(X).Select
         ' Makes chart active.
         ActiveSheet.ChartObjects(X).Activate
         'Set the colour to black and white
        ActiveChart.PageSetup.BlackAndWhite = False
         ' Prints one copy of active chart.
         ActiveChart.PrintOut Copies:=1
     Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,650
Messages
6,120,734
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top