Problem with Addin in Microsoft Excel

Add-in Express™ Support Service
That's what is more important than anything else

Problem with Addin in Microsoft Excel
Excel crashes when opening documents 
Sergey Grischenko

Add-in Express team

Posts: 7235
Joined: 2004-07-05
Hi Mike.

I have just run the code below. It works fine while Excel is shutting down with several workbooks opened. You can test the code on your PC if you wish.

Private Sub adxExcelEvents_WorkbookBeforeClose(ByVal sender As Object, ByVal e As AddinExpress.MSO.ADXHostBeforeActionEventArgs) Handles adxExcelEvents.WorkbookBeforeClose
Dim iWBcount As Integer
Dim i, p As Integer
Dim Cancel As Boolean = False
Dim wb As Excel.Workbook = Nothing
Dim wbooks As Excel.Workbooks = Nothing
Dim properties As Office.DocumentProperties = Nothing
Dim prop As Office.DocumentProperty = Nothing
Dim pname As String
Dim pvalue As Object

wbooks = ExcelApp.Workbooks
iWBcount = wbooks.Count
For i = 1 To iWBcount
wb = Nothing
properties = Nothing
wb = wbooks.Item(i)
properties = wb.CustomDocumentProperties
For p = 1 To properties.Count
prop = Nothing

prop = properties.Item(p)
pname = prop.Name
pvalue = prop.Value
MsgBox(pname + ": " + pvalue.ToString())
If Not prop Is Nothing Then
End If
End Try
If Not properties Is Nothing Then
End If
If Not wb Is Nothing Then
End If
End Try
If Not wbooks Is Nothing Then
End If
End Try

End Sub
Posted 14 Jun, 2006 09:21:27 Top
Michael McMahon

Posts: 56
Joined: 2005-05-03
Hi Sergey,

Thanks for that code. I've modified my code to use the Marshal.ReleaseComObject function call and that does seem to work a lot better.

I've also found some code in another client side component of ours which seeemed to be directly causing the safe mode issue highlighted above. I believe this means that our problem has been resolved.

Again your assistance has been invaluable,

Michael McMahon
Posted 15 Jun, 2006 01:04:59 Top