If NewFolder Is Nothing Then Exit Sub Set objAE = Application.GetNamespace("MAPI").CurrentUser If lsDLMember("HR Admins",objAE) = False Then If NewFolder.Name = "Salary Guidelines" Then MsgBox "You do not have permission to access this folder." _ & vbCr & "If you believe you should have access to this folder," & vbCr & "please contact your departmental HR supervisor.", _ vbCritical Cancel = True End If End If End Sub
It NewFolder is a folder in the file system, then NewFolder is Nothing. Your code should provide for this possibility.
The BeforeViewSwitch event is similar to the BeforeFolderSwitch event, except that it occurs before a view is switched to a new view, either through a user action or programmatically. If a user changes from the Contacts folder to the Tasks folder but does not explicitly change the view with the View selector, the BeforeViewSwitch event will not fire, even though the default views on the two folders have different names. This event is cancelable. The event procedure prevents the user from switching to the view named Message Timeline if there are more than 500 items in the current folder.
Private Sub objExpl_BeforeViewSwitch(ByVal NewView As Variant, _ Cancel As Boolean) If NewView = "Message Timeline" Then
If objExpl.CurrentFolder.ltems.Count > 500 Then
Cancel = True End If End If End Sub
The Close event occurs when an Explorer object closes as a result of a user action or program code. Don't confuse this event with the Close method, which causesthe Explorer window to close. The following example sets several Outlook Bar objects to Nothing when the Explorer window Close event fires:
Private Sub objExpl_Close() Set objPane = Nothing Set objContents = Nothing Set colOutlookBarGroups = Nothing
Was this article helpful?