I am building an app that will build customer based powerpoint presentations overnight based upon user requests. I am having difficulty with some charts they want in the presentations. I found some code that will export a form chart as a jpg file, but from the open form. I need to loop through a set of reports, and if the report contains data, export the report chart to a jpg, that I can then insert into a powerpoint slide created using vba. The form based syntax is as follows:
Private Sub cmdExportGraph_Click()
'=============================================
' Purpose: Export Graph
' E-Mail: Graeme Dot Wilson AT nationsbank Dot co Dot uk
' Programmer: Graeme Wilson
'=============================================
On Error GoTo cmdExportGraph_Click_Err
Dim strErrMsg As String 'For Error Handling
Dim oleGrf As Object
Dim strFileName As String
Dim strFilter As String
Dim lngFlags As Long
Set oleGrf = Me.OLEchart.Object
strFileName = ahtCommonFileOpenSave(Flags:=lngFlags, InitialDir:="C:\", _
Filter:="JPEG Files (*.jpg)", FilterIndex:=1, DefaultExt:="jpg", FileName:="MyGraph", _
DialogTitle:="Save the Graph", OpenFile:=False)
oleGrf.Export FileName:=strFileName
MsgBox vbCrLf & "The Chart " & strFileName & " has been exported", _
vbInformation + vbOKOnly, "Chart Exported :"
cmdExportGraph_Click_Exit:
Set oleGrf = Nothing
Exit Sub
cmdExportGraph_Click_Err:
Select Case Err
Case 1004 ' Export Cancelled
Resume cmdExportGraph_Click_Exit
Case Else
strErrMsg = strErrMsg & "Error #: " & Format$(Err.Number) & vbCrLf & vbCrLf
strErrMsg = strErrMsg & "Error Description: " & Err.Description & vbCrLf
MsgBox strErrMsg, vbInformation, "cmdExportGraph_Click"
Resume cmdExportGraph_Click_Exit
End Select
End Sub
I need to replace the line referring to the form chart:
Set oleGrf = Me.OLEchart.Object
with a line that refers to a report chart that is not open. Does anyone know the syntax I should use?
Many thanks,
Andy
Private Sub cmdExportGraph_Click()
'=============================================
' Purpose: Export Graph
' E-Mail: Graeme Dot Wilson AT nationsbank Dot co Dot uk
' Programmer: Graeme Wilson
'=============================================
On Error GoTo cmdExportGraph_Click_Err
Dim strErrMsg As String 'For Error Handling
Dim oleGrf As Object
Dim strFileName As String
Dim strFilter As String
Dim lngFlags As Long
Set oleGrf = Me.OLEchart.Object
strFileName = ahtCommonFileOpenSave(Flags:=lngFlags, InitialDir:="C:\", _
Filter:="JPEG Files (*.jpg)", FilterIndex:=1, DefaultExt:="jpg", FileName:="MyGraph", _
DialogTitle:="Save the Graph", OpenFile:=False)
oleGrf.Export FileName:=strFileName
MsgBox vbCrLf & "The Chart " & strFileName & " has been exported", _
vbInformation + vbOKOnly, "Chart Exported :"
cmdExportGraph_Click_Exit:
Set oleGrf = Nothing
Exit Sub
cmdExportGraph_Click_Err:
Select Case Err
Case 1004 ' Export Cancelled
Resume cmdExportGraph_Click_Exit
Case Else
strErrMsg = strErrMsg & "Error #: " & Format$(Err.Number) & vbCrLf & vbCrLf
strErrMsg = strErrMsg & "Error Description: " & Err.Description & vbCrLf
MsgBox strErrMsg, vbInformation, "cmdExportGraph_Click"
Resume cmdExportGraph_Click_Exit
End Select
End Sub
I need to replace the line referring to the form chart:
Set oleGrf = Me.OLEchart.Object
with a line that refers to a report chart that is not open. Does anyone know the syntax I should use?
Many thanks,
Andy