ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Print Charts (https://www.excelbanter.com/excel-programming/391425-print-charts.html)

Beep Beep

Print Charts
 
I have twelve workbooks that each contain 2 worksheets. One worksheet
contains data and the other contains a chart.

Is there a way that I can call up the individual workbooks and then print
out just the chart tab, save and call up the next workbook. All this done
with one Macro.

Thanks
Frank

JLatham

Print Charts
 
Little doubt that it could be done. You could write code that lists all
workbook's complete paths/names and have it open them one at a time, find a
sheet with a chart on it (be nice if chart sheets all had same name), and
print the sheet within a loop.
Another way would be to have only those files in a specific folder and have
your macro simply access each .xls file in the folder in turn (except for
itself) and then do same process regarding finding the chart sheet(s) and
printing them.

"Beep Beep" wrote:

I have twelve workbooks that each contain 2 worksheets. One worksheet
contains data and the other contains a chart.

Is there a way that I can call up the individual workbooks and then print
out just the chart tab, save and call up the next workbook. All this done
with one Macro.

Thanks
Frank


kounoike[_2_]

Print Charts
 
give this one a try.
run this, then a dialog comes up and select a folder that has your files.
I presume your files are in a same folder. this would try to print every
graph in workbooks in the folder, as i'm not sure your graphs are in
worksheets or in graph sheet.

Sub printcharts()
Dim wb, fd
Dim sh As Worksheet
Dim chobj As ChartObject
Dim ch As Chart
Dim xlFile As String
Dim MyPath As String

Set fd = Application.FileDialog(msoFileDialogFolderPicker)

If fd.Show = -1 Then
MyPath = fd.SelectedItems(1)
Else
Exit Sub
End If
ChDir MyPath
xlFile = Dir("*.xls")
On Error Resume Next
Application.DisplayAlerts = False
Do While xlFile < ""
If ThisWorkbook.Name < xlFile Then
Set wb = Workbooks.Open(MyPath & _
Application.PathSeparator & xlFile)
End If
'print every worksheets that have graphs
For Each sh In worksheets
Set chobj = Nothing
Set chobj = sh.ChartObjects(1)
If Not chobj Is Nothing Then
sh.PrintOut 'preview:=True
End If
Next
'print every Graph sheets
For Each ch In Charts
ch.PrintOut 'preview:=True
Next
wb.Close SaveChanges:=False
xlFile = Dir
Loop
End Sub

keizi

"Beep Beep" wrote in message
...
I have twelve workbooks that each contain 2 worksheets. One worksheet
contains data and the other contains a chart.

Is there a way that I can call up the individual workbooks and then print
out just the chart tab, save and call up the next workbook. All this done
with one Macro.

Thanks
Frank




All times are GMT +1. The time now is 03:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com