Hi,
Reading various properties of the Outlook.MAPIFolder.Items collection results in an error when the user permissions are insufficient, for example if the folder is visible but no browsable.
The error description is: You do not have sufficient permission to perform this operation on this object. See the folder contact or your system administrator.
I wanted to trap that error this way (in Outlook 2003):
Sub MySub(StartFolder As Outlook.MAPIFolder)
...
On Error GoTo ErrHandler
If (StartFolder.Items.Count = 0) Then Exit Sub 'this really is a permission test'
On Error GoTo 0
...
ErrHandler:
If ((Err.Number <> 0) And (Err.Number <> -2114519035)) Then
Call MsgBox("Error " & Err.Number & ": " & Err.Description, vbExclamation + vbOKOnly, StartFolder.Name, _
Err.HelpFile, Err.HelpContext)
...
End Sub
Testing my error handler, I found another error number having the same description... and the list grew quickly to 62 errors having the same description! Err.Number ranges from -2114519035 to -1638395. All error numbers look like FFxxx70005 in hex.
Why is there multiple Err.Number for the same Err.Description? How would you trap these errors, and only them, easily? Is the hex error number structure characteristic of this error?
Oh, and I don't like the idea of testing the description (too locale- and version-specific).