Example The Print SelectedCharts Procedure

Sub PrintSelectedCharts()

' Print the selected charts in lstCharts

Dim i As Integer

Dim bNoneSelected As Boolean bNoneSelected = True

If cCharts = 0 Then

MsgBox "No embedded charts in this workbook.", vbExclamation Exit Sub Else

For i = 0 To lstCharts.ListCount - 1 If lstCharts.Selected(i) Then bNoneSelected = False

' List box is 0-based, arrays are 1-based Worksheets(sSheets(i + 1)).

ChartObjects(sChartObjNames(i + 1)).Chart.PrintOut

End If Next End If

If bNoneSelected Then

MsgBox "No charts have been selected from the list box.", vbExclamation

End If End Sub

0 0

Post a comment