M
Muechel
hi ng,
i want to open a pst file from the network, if the connection exists. to open
the file works fine, but i can not remove the file in application_quit
problem:
in the application_quit i get no access to the mapi folders. error message:
80004005 automation error
code:
Private Const szProjects = "<path to pst file>" ' like \\server\share\file.pst
Private Sub Application_Startup()
On Error Resume Next
Dim nsProjects As Outlook.NameSpace
Set nsProjects = Application.GetNamespace("MAPI")
If fso.FileExists(szProjects) Then
nsProjects.AddStore szProjects
Else
Dim fldProjects As MAPIFolder
If Not MAPIFolderExists(nsProjects.Folders, "Projects") Then Exit Sub
Set fldProjects = nsProjects.Folders.Item("Projects")
nsProjects.RemoveStore fldProjects
Set fldProjects = Nothing
End If
Set nsProjects = Nothing
End Sub
Private Sub Application_Quit()
Dim nsProjects As Outlook.NameSpace
Set nsProjects = Application.GetNamespace("MAPI")
' automation error occurs
If Not fld(2).Name = "<folder name>" Then Exit Sub
Dim fldProjects As Outlook.MAPIFolder
Set fldProjects = nsProjects.Folders.Item("Projects")
nsProjects.RemoveStore fldProjects
Set fldProjects = Nothing
Set nsProjects = Nothing
End Sub
i've also tried to create a new instance of the application object. i there any
solution for this problem.
can anybody help me?
i want to open a pst file from the network, if the connection exists. to open
the file works fine, but i can not remove the file in application_quit
problem:
in the application_quit i get no access to the mapi folders. error message:
80004005 automation error
code:
Private Const szProjects = "<path to pst file>" ' like \\server\share\file.pst
Private Sub Application_Startup()
On Error Resume Next
Dim nsProjects As Outlook.NameSpace
Set nsProjects = Application.GetNamespace("MAPI")
If fso.FileExists(szProjects) Then
nsProjects.AddStore szProjects
Else
Dim fldProjects As MAPIFolder
If Not MAPIFolderExists(nsProjects.Folders, "Projects") Then Exit Sub
Set fldProjects = nsProjects.Folders.Item("Projects")
nsProjects.RemoveStore fldProjects
Set fldProjects = Nothing
End If
Set nsProjects = Nothing
End Sub
Private Sub Application_Quit()
Dim nsProjects As Outlook.NameSpace
Set nsProjects = Application.GetNamespace("MAPI")
' automation error occurs
If Not fld(2).Name = "<folder name>" Then Exit Sub
Dim fldProjects As Outlook.MAPIFolder
Set fldProjects = nsProjects.Folders.Item("Projects")
nsProjects.RemoveStore fldProjects
Set fldProjects = Nothing
Set nsProjects = Nothing
End Sub
i've also tried to create a new instance of the application object. i there any
solution for this problem.
can anybody help me?