LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default EXCEL.EXE process does not end after adding an excel chart

Hi,

I have VB .NET function below that creates an excel document. It
works fine and the Excel.exe process ends except when I try to add a
chart. When I include the code here I cannot cleanly end the Excel.exe
process:

xlChart.ChartType = Excel.XlChartType.xlXYScatterLines

Once I include that code the EXCEL.EXE process is still in the task
manager.

What can I do to close the EXCEL.EXE process?

Thanks,

Marc

Code:

Imports Excel = Microsoft.Office.Interop.Excel

Function CreateExcelPlot() As String
Dim plotFilePath As String = Nothing
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlDataSheet As Excel.Worksheet
Dim xlChartSheet As Excel.Worksheet
Dim xlChart As Excel.Chart

'Initiate Excel, hide the application, and add a workbook. In
case you were wondering, by referring to the Excel
'application, the program is initiated
xlApp = New Excel.Application
xlApp.Visible = False
xlBook = xlApp.Workbooks.Add()
xlDataSheet = CType(xlBook.Worksheets.Add(), Excel.Worksheet)
xlChartSheet = CType(xlBook.Worksheets.Add(), Excel.Worksheet)
xlChart = xlApp.Charts.Add
xlChart.ChartType = Excel.XlChartType.xlXYScatterLines 'Once
I include this, I can't cleanly close EXCEL.EXE

xlDataSheet.Cells(1, 1) = DateValue("January 1, 2003")
xlDataSheet.Cells(1, 2) = 30
xlDataSheet.Cells(2, 1) = DateValue("February 1, 2003")
xlDataSheet.Cells(2, 2) = 35
xlDataSheet.Cells(3, 1) = DateValue("March 1, 2003")
xlDataSheet.Cells(3, 2) = 31
xlDataSheet.Cells(4, 1) = DateValue("April 1, 2003")
xlDataSheet.Cells(4, 2) = 36
'xlChart.SetSourceData(xlDataSheet.Range("A1:B4")) Ignore for
now

plotFilePath = "C:\Test13.xls"

Try
My.Computer.FileSystem.DeleteFile(plotFilePath)
Catch
End Try

xlBook.SaveAs(plotFilePath)


xlBook.Close()
xlApp.Workbooks.Close()
xlApp.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComO bject(xlApp)
System.Runtime.InteropServices.Marshal.ReleaseComO bject
(xlDataSheet)
System.Runtime.InteropServices.Marshal.ReleaseComO bject
(xlChartSheet)
System.Runtime.InteropServices.Marshal.ReleaseComO bject
(xlChart)
System.Runtime.InteropServices.Marshal.ReleaseComO bject
(xlBook)
xlApp = Nothing
xlBook = Nothing
xlDataSheet = Nothing
xlChartSheet = Nothing
xlChart = Nothing
GC.Collect()
return plotFilePath
End Function
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
adding a single label on excel chart Eric_G Charts and Charting in Excel 1 October 2nd 09 10:22 PM
Adding a Benchmark line in an Excel chart John Krsulic[_2_] Charts and Charting in Excel 2 May 16th 08 04:53 PM
Adding a control line to excel chart without showing up in the leg TWeaver Charts and Charting in Excel 4 September 18th 07 11:00 PM
Adding custom graphics to excel chart Ukko Excel Programming 0 February 6th 06 09:41 AM
Adding a certain text label in a excel chart Tim Charts and Charting in Excel 2 September 28th 05 08:03 PM


All times are GMT +1. The time now is 08:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"