I've found it impossible to use the Chart Export facility in a Excel VB.NET from the Microsoft.Office.Interop.Excel references.
The system is as follows:-
VB.NET 2003 Version 7.1.3088
.NET Framework 1.1 Version 1.1.4322 SP1
Microsoft XP Pro, Version 2002 SP2.
My cut down code to show the problem is as follows, and is called simply by clicking a button on a Form with nothing else on it:-
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim objexcel As Microsoft.office.interop.excel.Application
Dim objchart As Microsoft.office.interop.Excel.Chart
objexcel =
New Microsoft.office.interop.excel.Applicationobjchart = New Microsoft.Office.Interop.Excel.Chart
objexcel.Workbooks.Add()
objexcel.Sheets.Add()
objexcel.Range("A1").Value = "Name"
objexcel.Range("A2").Value = "Ann"
objexcel.Range("A3").Value = "Jeo"
objexcel.Range("B1").Value = "Score"
objexcel.Range("B2").Value = "11"
objexcel.Range("B3").Value = "15"
objexcel.Range("A1:B3").Select()
objchart = objexcel.Charts.Add()
objchart.Location(Microsoft.Office.Interop.Excel.XlChartLocation.xlLocationAsNewSheet)
objchart.HasTitle = True
objchart.ChartTitle.Characters.Text = "THIS IS A TEST"
objexcel.ActiveWorkbook.SaveAs(filenamevalue)
objexcel.ActiveChart.Select()
Dim value = objexcel.CutCopyMode()objexcel.ActiveChart.Export("C:\Inetpub\wwwroot\spreadsheets\sav\test.gif", "gif") End Sub
End
ClassThe error is:-

Problem using Chart Export with VB .NET on MS Office 2003 on XP
wxhhxw
I am currently having the same issue. I've posted here, but since this issue discussed COM configuration (see here), I thought I'd try posting here as well. I am building a webservice in C# with Excel 2003. I want to create a chart and export it as a PNG. I get the error when running on a 2003 server, but not when I run it from within VS2005 on my XP development PC.
Any ideas
Jim Ward
Dan:
Did pace_uk's reply answer your question I'm assuming at this point that it did as you haven't posted a reply otherwise.
Please mark pace_uk's question as the answer if it did indeed help you.
Thanks so much!
Mike Hernandez
Community Program Manager
VSTO Team
Rob McCabe
I would just double check that you have the appropriate image in your resouces folder of the project ;-)
SlayerGatsu
Actually, this is a non-VSTO related issue. If you're still having difficulty with this, please repost your question in the excel.charting newsgroup. Here's the link:
http://msdn.microsoft.com/newsgroups/default.aspx dg=microsoft.public.excel.charting&lang=en&cr=US
Thanks!
Mike Hernandez
Community Program Manager
VSTO Team