Public Function ExportToGif(ByVal strFileName As String)
On Error GoTo hError
'--- 检查图表中是否确实存在数据
If (oExcelChart.SeriesCollection.Count < = 0) Then
Err.Raise Number:=1001 + vbObjectError, _
Description:="No data series in chart"
ExportToGif = -1
'--- 检查文件名字是否合法
ElseIf (IsNull(strFileName) Or Trim(strFileName) = "") Then
Err.Raise Number:=1001 + vbObjectError, _
Description:="Invalid file name for export"
ExportToGif = -1
'--- 导出GIF文件
Else
oExcelChart.Export strFileName, "GIF": ExportToGif = 1
End If
Exit Function
hError:
ExportToGif = -1
App.LogEvent Err.Description, vbLogEventTypeError
Err.Raise Err.Number, Err.Source, Err.Description
End Function
|