screechowl
New member
- Joined
- Jul 8, 2003
- Messages
- 3
Im having trouble with the Excel Chart object. Does anyone know how to properly create one? The following code works; however, the Excel process hangs. If I comment out the Chart object, then the process does not hang.
Dim xlApp As New Excel.Application()
xlApp.Visible = True
xlApp.DisplayAlerts = False
xlApp.UserControl = False
Dim xlWrkbks As Excel.Workbooks = xlApp.Workbooks
Dim xlWrkbk As Excel.Workbook = xlWrkbks.Add
Dim xlWrkst As Excel.Worksheet
xlWrkst = xlApp.ActiveSheet()
Dim xlChartObj As Excel.Chart = xlWrkbk.Charts.Add
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlChartObj)
xlChartObj = Nothing
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlWrkst)
xlWrkst = Nothing
xlWrkbk.Close()
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlWrkbk)
xlWrkbk = Nothing
xlWrkbks.Close()
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlWrkbks)
xlWrkbks = Nothing
xlApp.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp)
xlApp = Nothing
GC.Collect()
GC.WaitForPendingFinalizers()
Dim xlApp As New Excel.Application()
xlApp.Visible = True
xlApp.DisplayAlerts = False
xlApp.UserControl = False
Dim xlWrkbks As Excel.Workbooks = xlApp.Workbooks
Dim xlWrkbk As Excel.Workbook = xlWrkbks.Add
Dim xlWrkst As Excel.Worksheet
xlWrkst = xlApp.ActiveSheet()
Dim xlChartObj As Excel.Chart = xlWrkbk.Charts.Add
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlChartObj)
xlChartObj = Nothing
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlWrkst)
xlWrkst = Nothing
xlWrkbk.Close()
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlWrkbk)
xlWrkbk = Nothing
xlWrkbks.Close()
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlWrkbks)
xlWrkbks = Nothing
xlApp.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp)
xlApp = Nothing
GC.Collect()
GC.WaitForPendingFinalizers()