Greetings,

I'd like to print ALL of my charts out to one PDF. In looking around the forums, the solutiion appears to be looping through the worksheets, checking the sheet type, then adding the name to an ever-increasing array, and then identifying the array in a "sheets.select" method.

So, I've cobbled up the following code, but get an error saying "Subscript out of range" on the last line. Any ideas? Also, rather than using the numeric identifier sheet.type = 3, could I use "xlChart"? I tried that syntax but it didn't like it.

Sub SaveAndPrintPDFAndExcelFiles(ByVal x1 As Excel.Application, strFilename)
Dim i As Integer
Dim j As Integer
strFilename = GetDBPath & "Hydrographs\" & strFilename
x1.Application.DisplayAlerts = False
x1.ActiveWorkbook.SaveAs FileName:=strFilename, FileFormat:= _
xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
x1.Application.DisplayAlerts = True
Dim Arr()
For i = 1 To x1.Sheets.Count
If x1.Sheets(i).Type = 3 Then
j = j + 1
ReDim Preserve Arr(j)
Arr(j) = Sheets(i).Name
End If
Next
x1.Sheets(Arr).Select
x1.ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, FileName:=GetDBPath & "Hydrographs\" & strFilename & ".pdf", OpenAfterPublish:=True
End Sub


Thanks for any help folks can provide!

Jonathan Mulder
Engineering Geologist
California Department of Water Resources