Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I'm 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()

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...