Everything works fine in the BeforeFolderSwitch code except when Cancel = True, Windows then produces a critical error message and shuts down Outlook.
I've tried this using VBA directly in Outlook and also building it into an Add-In for Outlook. In both cases the code produces the same problem.
I changed the code several times to see if the sub is entered and if the new folder object contains anything. I then included a message box to question if the folder should be changed yes/no to set it at will, and error handling. The code runs as wished with out errors all the way up to End Sub, After which Windows then brings up a critical error message reffering to a page fault in outllib.dll.
Enviroment : Win98/Outlook2000/VB6 Pro
Code is example code from Microsoft
Dim myOlApp As Outlook.Application
Public WithEvents myOlExp As Outlook.Explorer
Public Sub Initialize_handler()
Set myOlExp = myOlApp.ActiveExplorer
End Sub
Private Sub myOlExp_BeforeFolderSwitch(ByVal NewFolder As Object, Cancel As Boolean)
If NewFolder.Name = "Off Limits" Then
MsgBox "You do not have permission to access this folder."
Cancel = True
End If
End Sub
I've tried this using VBA directly in Outlook and also building it into an Add-In for Outlook. In both cases the code produces the same problem.
I changed the code several times to see if the sub is entered and if the new folder object contains anything. I then included a message box to question if the folder should be changed yes/no to set it at will, and error handling. The code runs as wished with out errors all the way up to End Sub, After which Windows then brings up a critical error message reffering to a page fault in outllib.dll.
Enviroment : Win98/Outlook2000/VB6 Pro
Code is example code from Microsoft
Dim myOlApp As Outlook.Application
Public WithEvents myOlExp As Outlook.Explorer
Public Sub Initialize_handler()
Set myOlExp = myOlApp.ActiveExplorer
End Sub
Private Sub myOlExp_BeforeFolderSwitch(ByVal NewFolder As Object, Cancel As Boolean)
If NewFolder.Name = "Off Limits" Then
MsgBox "You do not have permission to access this folder."
Cancel = True
End If
End Sub