Outlook crashes during shutdown after running operation

  • Thread starter Thread starter grandmastermjm
  • Start date Start date
G

grandmastermjm

I have a COM addin (VB6), that had run without error until recently.
When the following code is run, the microsoft error reporting window
comes up when outlook is closing after the onBeginShutdown and after
the onDisconection events.

Private Sub ExecuteButton_Click()
' Code renames two archive folders on in a pst file and one in the
public folders.
On Error Resume Next
If Utilities.connected = False Then
MsgBox ("You need to be connected to Exchange to use this
feature.")
Exit Sub
End If

Dim prospectName As String
Dim customerName As String
prospectName = ProspectList.Text
customerName = CustomerList.Text

Dim publicFolder As Redemption.RDOFolder
Set publicFolder = MAPIFunctions.getRDOFolderPublic 'gets reference
created at addin load.
Set publicFolder = publicFolder.Folders("History")
Set publicFolder = publicFolder.Folders(Utilities.getUserName) '
function from Sue Mosher's Outlook Programming book (gets name from
root store name
'If Not publicFolder.Folders(prospectName) Is Nothing Then
Set publicFolder = publicFolder.Folders(prospectName)
'End If
If publicFolder Is Nothing Then
Set publicFolder =
MAPIFunctions.getRDOFolderPublic.Folders("History").Folders(Utilities.getUserName).Folders.Add(prospectName)
'gets reference created at addin load.
End If

Dim archiveFolder As Redemption.RDOFolder
Set archiveFolder =
MAPIFunctions.getRDOFolderArchive.Folders(prospectName) 'gets reference
created at addin load.
If archiveFolder Is Nothing Then
Set archiveFolder = MAPIFunctions.getRDOFolderArchive 'gets
reference created at addin load.
Set archiveFolder = archiveFolder.Folders.Add(prospectName)
End If

If Not publicFolder Is Nothing Then
publicFolder.name = customerName
End If
archiveFolder.name = customerName
Set publicFolder = Nothing
Set archiveFolder = Nothing

Unload Me
End Sub

I can load the form and click on the exit command, and I don't get an
error. I have spent many hours, but I cannot find any problems. The
onDisconnection event fires, and all objects are set to nothing, but I
cannot find the problem.

The specific error is:
Unhandled exception at 0x66021883 in OUTLOOK.EXE: 0xC0000005: Access
violation reading location 0x00000008.

Thanks for any help.
 
I think that I found a work-around. If I run the code to get the user's
name when the addin loads, and store it in a variable, and then access
the variable when I need the user's name, Outlook does not crash upon
closing.
 
Back
Top