Previous Thread

8/17/2006 2:59:30 PM    PivotTables interop reference causes crash in Excel 2000
The following VB.NET code (even extracted from other actions and 
 
stripped of error handling) opens the pivot table correctly, but when I 
 
attempt to close Excel, I get an application error from EXCEL.EXE (The 
 
instruction at "0x300341b6" referenced memory at "0x650418f0". The 
 
memory could not be "read".) and the EXCEL.EXE process continues to 
 
run. 
 
Opening the report in question directly in Excel does not cause errors 
 
when Excel is closed. 
 
The only occurs in Excel 2000;  in Excel XP, I get no errors. 
 
Dim oApp As Interop.Excel.ApplicationClass 
 
Dim oWorkBook As Interop.Excel.Workbook 
 
Dim oWorkSheet As Interop.Excel.Worksheet 
 
Dim oPivotTable As Interop.Excel.PivotTable 
 
oApp = New Excel.ApplicationClass 
 
oWorkBook = objApp.Workbooks.Open(strExcelFile) 
 
oWorkSheet = oWorkBook.ActiveSheet() 
 
oPivotTable = oWorkSheet.PivotTables(1) 
 
oPivotTable.PivotCache.LocalConnection = "OLEDB;Provider=MSOLAP;Data 
 
Source=" + strCubeFile 
 
oPivotTable.PivotCache.UseLocalConnection = True 
 
oApp.Visible = True 
 
oPivotTable = Nothing 
 
oWorkSheet = Nothing 
 
oWorkBook = Nothing 
 
oApp = Nothing 
 
GC.Collect() 
 
(I know that forcing the garbage collection is bad;  I've been trying 
 
everything I could think of to release the COM objects, and the pivot 
 
table just won't let go.) 
 
Does anyone know what's happening here? 
 
Thanks, 
 
Caitlin Shaw