A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Charts and Charting
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

exporting a chart to gif format using COM (Excel v11 and .net)



 
 
Thread Tools Display Modes
  #1  
Old December 30th, 2004, 11:07 PM
Katie
external usenet poster
 
Posts: n/a
Default exporting a chart to gif format using COM (Excel v11 and .net)

Hi,

I've created a chart in .net (vb) and now I'm trying to export my chart as a
gif but I'm getting an "Exception from HRESULT:
0x800A03EC.:System.Runtime.InteropServices.COMExce ption"

I think I know why I am getting the exception but I don't know how to
specify the FILTERNAME object that the method wants

Dim oXLChart As Excel.Chart
oXLChart = oXLSheet.Parent.Charts.Add
oXLChart.ChartType = Excel.XlChartType.xlXYScatterSmooth
oXLChart.SetSourceData(oXLRange,
oXLChartClass.PlotBy.xlColumns)

oXLChart.Location(Excel.XlChartLocation.xlLocation AsNewSheet, "TEST2")
oXLChart.SeriesCollection.Add(oXLYRange)

Try
oXLSeriesCollect = oXLChart.SeriesCollection
oXLSeriesCollect.Item(oXLSeriesCollect.Count).Sele ct()
With oXLSeriesCollect.Item(oXLSeriesCollect.Count)
.AxisGroup = Excel.XlAxisGroup.xlSecondary
.Border.Color = RGB(30, 144, 255)
.Border.LineStyle = Excel.XlLineStyle.xlContinuous
.Border.Weight = Excel.XlBorderWeight.xlThin
.MarkerBackgroundColorIndex = 38
.MarkerForegroundColorIndex = 41
.MarkerStyle = Excel.Constants.xlTriangle
.Smooth = True
.MarkerSize = 5
.Shadow = False
End With

Catch ex As Exception
curError = New SBTestError
curError.SetError(curError.generalError, "UNEXPEDTED
ERROR!!" + ex.Message & ":" + ex.GetType.ToString() + ": " & ex.StackTrace)
sbErrorCollection.Add(curError)
End Try

'do some formating stuff then try to export,

oXLChart.Export("c:\temp\katieimage.gif", "gif", False)


The definition for chart export method is Export(ByVal Filename As String,
ByVal FilterName As Object..,By Val Interactive As Object) As boolean


Has anyone else tried to use this method and are able to specify the
filtername parameter?

I know others have used the Microsoft.Office.Interop.Owc11 Chartspace export
picture method but I'd have to rewrite all the code to create the chart.

Thanks!


  #2  
Old December 31st, 2004, 01:13 AM
Don Guillett
external usenet poster
 
Posts: n/a
Default

Maybe this simpler approach will help.

Sub ExportChartGIF()
ActiveChart.Export Filename:="C:\a\MyChart.gif", _
FilterName:="GIF"
End Sub
Sub ExportChartJPG()
ActiveChart.Export Filename:="C:\a\MyChart.jpg", _
FilterName:="jpeg"
End Sub


--
Don Guillett
SalesAid Software

"Katie" wrote in message
...
Hi,

I've created a chart in .net (vb) and now I'm trying to export my chart as

a
gif but I'm getting an "Exception from HRESULT:
0x800A03EC.:System.Runtime.InteropServices.COMExce ption"

I think I know why I am getting the exception but I don't know how to
specify the FILTERNAME object that the method wants

Dim oXLChart As Excel.Chart
oXLChart = oXLSheet.Parent.Charts.Add
oXLChart.ChartType = Excel.XlChartType.xlXYScatterSmooth
oXLChart.SetSourceData(oXLRange,
oXLChartClass.PlotBy.xlColumns)

oXLChart.Location(Excel.XlChartLocation.xlLocation AsNewSheet, "TEST2")
oXLChart.SeriesCollection.Add(oXLYRange)

Try
oXLSeriesCollect = oXLChart.SeriesCollection
oXLSeriesCollect.Item(oXLSeriesCollect.Count).Sele ct()
With oXLSeriesCollect.Item(oXLSeriesCollect.Count)
.AxisGroup = Excel.XlAxisGroup.xlSecondary
.Border.Color = RGB(30, 144, 255)
.Border.LineStyle = Excel.XlLineStyle.xlContinuous
.Border.Weight = Excel.XlBorderWeight.xlThin
.MarkerBackgroundColorIndex = 38
.MarkerForegroundColorIndex = 41
.MarkerStyle = Excel.Constants.xlTriangle
.Smooth = True
.MarkerSize = 5
.Shadow = False
End With

Catch ex As Exception
curError = New SBTestError
curError.SetError(curError.generalError, "UNEXPEDTED
ERROR!!" + ex.Message & ":" + ex.GetType.ToString() + ": " &

ex.StackTrace)
sbErrorCollection.Add(curError)
End Try

'do some formating stuff then try to export,

oXLChart.Export("c:\temp\katieimage.gif", "gif", False)


The definition for chart export method is Export(ByVal Filename As String,
ByVal FilterName As Object..,By Val Interactive As Object) As boolean


Has anyone else tried to use this method and are able to specify the
filtername parameter?

I know others have used the Microsoft.Office.Interop.Owc11 Chartspace

export
picture method but I'd have to rewrite all the code to create the chart.

Thanks!




  #3  
Old December 31st, 2004, 06:04 AM
Jon Peltier
external usenet poster
 
Posts: n/a
Default

Dunno about all that .Net stuff, but this works in regular VBA:

oXLChart.Export "c:\temp\katieimage.gif", "gif"

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______

Katie wrote:

Hi,

I've created a chart in .net (vb) and now I'm trying to export my chart as a
gif but I'm getting an "Exception from HRESULT:
0x800A03EC.:System.Runtime.InteropServices.COMExce ption"

I think I know why I am getting the exception but I don't know how to
specify the FILTERNAME object that the method wants

Dim oXLChart As Excel.Chart
oXLChart = oXLSheet.Parent.Charts.Add
oXLChart.ChartType = Excel.XlChartType.xlXYScatterSmooth
oXLChart.SetSourceData(oXLRange,
oXLChartClass.PlotBy.xlColumns)

oXLChart.Location(Excel.XlChartLocation.xlLocation AsNewSheet, "TEST2")
oXLChart.SeriesCollection.Add(oXLYRange)

Try
oXLSeriesCollect = oXLChart.SeriesCollection
oXLSeriesCollect.Item(oXLSeriesCollect.Count).Sele ct()
With oXLSeriesCollect.Item(oXLSeriesCollect.Count)
.AxisGroup = Excel.XlAxisGroup.xlSecondary
.Border.Color = RGB(30, 144, 255)
.Border.LineStyle = Excel.XlLineStyle.xlContinuous
.Border.Weight = Excel.XlBorderWeight.xlThin
.MarkerBackgroundColorIndex = 38
.MarkerForegroundColorIndex = 41
.MarkerStyle = Excel.Constants.xlTriangle
.Smooth = True
.MarkerSize = 5
.Shadow = False
End With

Catch ex As Exception
curError = New SBTestError
curError.SetError(curError.generalError, "UNEXPEDTED
ERROR!!" + ex.Message & ":" + ex.GetType.ToString() + ": " & ex.StackTrace)
sbErrorCollection.Add(curError)
End Try

'do some formating stuff then try to export,

oXLChart.Export("c:\temp\katieimage.gif", "gif", False)


The definition for chart export method is Export(ByVal Filename As String,
ByVal FilterName As Object..,By Val Interactive As Object) As boolean


Has anyone else tried to use this method and are able to specify the
filtername parameter?

I know others have used the Microsoft.Office.Interop.Owc11 Chartspace export
picture method but I'd have to rewrite all the code to create the chart.

Thanks!



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Templates StrangerMike General Discussion 8 July 29th, 2004 12:45 AM
programatically change chart jmv Charts and Charting 10 July 25th, 2004 12:29 AM


All times are GMT +1. The time now is 04:17 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.