📄 clsoutlookexplorerevents.cls
字号:
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "clsOutlookExplorerEvents"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
'*********************************************************************
' copyright 2002 by Martin Nemzow (mnemzow@networkperf.com)
' You can use this code freely and distribute it.
' No warrantee granted or implied.
' this is a very loose modification of Randy Byrne's CBITEMS OUTLOOK
' COM Add-In in order to trap inspector events along side explorer events
' and watch the sequence of the events. The debugger works with it.
'
'... yes you can use this to add CommandBar items. But note that I have
' changed some variable names and added new classes with longer names
' so that it cuold be debugged and make some sense for reading to me.
' You are welcome to correct anything you want and tell me.
' the comments with '[2002] remove functionality available only in
' OUTLOOK 2002 and in OUTLOOK 2000. I appreciate everyone's efforts to
' decode how to automate Outlook, so if you have comments and changes
' I would very much appreciate it, and I think others will too.
'*********************************************************************
Option Explicit
'**************************************************
'Class: clsOutlookExplorerEvents
'**************************************************
Private WithEvents objOutlook As Outlook.Application
Attribute objOutlook.VB_VarHelpID = -1
Private WithEvents colExplorers As Outlook.Explorers
Attribute colExplorers.VB_VarHelpID = -1
Private WithEvents lclExplorer As Outlook.Explorer
Attribute lclExplorer.VB_VarHelpID = -1
Friend Sub InitHandler(olApp As Outlook.Application, strProgID As String)
Dim myAddIn As Office.COMAddIn
On Error Resume Next
Set objOutlook = olApp
Set gbl_objApplication = olApp
gbl_ProgID = strProgID
If colExplorers.Count >= 1 Then
Set colExplorers = objOutlook.Explorers
AddExplorer objOutlook.ActiveExplorer
End If
Set lclExplorer = objOutlook.ActiveExplorer
End Sub
Friend Sub UnInitHandler()
On Error Resume Next
Set lclExplorer = Nothing
Set colExplorers = Nothing
Set gbl_objApplication = Nothing
Set objOutlook = Nothing
End Sub
Private Sub colExplorers_NewExplorer(ByVal Explorer As Outlook.Explorer) 'Notifies your program that a new Explorer window has been created.
On Error Resume Next
MsgBox "NewExplorer: " & Explorer.Caption
AddExplorer Explorer
End Sub
Private Sub objOutlook_Startup()
On Error Resume Next
MsgBox "objStartup_Startup."
If colExplorers.Count Then
AddExplorer objOutlook.ActiveExplorer
End If
End Sub
'
'
'
'
'
'
Private Sub colExplorers_Activate() 'Notifies your program that an explorer or Explorer window has become the active window.
MsgBox "Explorers_Activate."
End Sub
'Private Sub colExplorers_BeforeFolderSwitch() 'Notifies your program that the user has attempted to change the folder displayed by an explorer. Your program can cancel the event to prevent the change.
'
'End Sub
'Private Sub colExplorers_BeforeGroupAdd() 'Notifies your program that the user has attempted to add a group to the Outlook Bar. Your program can cancel the event to prevent the change.
'
'End Sub
'Private Sub colExplorers_BeforeGroupRemove() 'Notifies your program that the user has attempted to remove a group from the Outlook Bar. Your program can cancel the event to prevent the change.
'
'End Sub
'Private Sub colExplorers_BeforeGroupSwitch() 'Notifies your program that the user has attempted to change the group displayed in the Outlook Bar. Your program can cancel the event to prevent the change.
'
'End Sub
'Private Sub colExplorers_BeforeShortcutAdd() 'Notifies your program that the user has attempted to add a shortcut to the Outlook Bar. Your program can cancel the event to prevent the change.
'
'End Sub
'Private Sub colExplorers_BeforeShortcutRemove() 'Notifies your program that the user has attempted to remove a shortcut from the Outlook Bar. Your program can cancel the event to prevent the change.
'
'End Sub
'Private Sub colExplorers_BeforeViewSwitch() 'Notifies your program that the user has attempted to change the view used to display the contents of a folder in an explorer window. Your program can cancel the event to prevent the change.
'
'End Sub
Private Sub colExplorers_Deactivate() 'Notifies your program that an explorer or Explorer window is no longer the active window.
MsgBox "Explorers_Activate."
End Sub
'Private Sub colExplorers_FolderAdd() 'Notifies your program that a folder has been added to a specific folders collection.
'
'End Sub
'Private Sub colExplorers_FolderChange() 'Notifies your program that a folder in a specific folders collection has been changed.
'
'End Sub
'Private Sub colExplorers_FolderRemove() 'Notifies your program that a folder has been deleted from a specific folders collection.
'
'End Sub
'Private Sub colExplorers_FolderSwitch() 'Notifies your program that the user has changed the folder displayed by an explorer window.
'
'End Sub
'Private Sub colExplorers_GroupAdd() 'Notifies your program that a group has been added to the Outlook Bar.
'
'End Sub
'Private Sub colExplorers_ItemAdd() 'Notifies your program that an item has been added to a specific items collection.
'
'End Sub
'Private Sub colExplorers_ItemChange() 'Notifies your program that an item in a specific items collection has been changed.
'
'End Sub
'Private Sub colExplorers_ItemRemove() 'Notifies your program that an item has been deleted from a specific items collection.
'
'End Sub
'Private Sub colExplorers_ItemSend() 'Notifies your program that the user has attempted to send an item. Your program can cancel the event to prevent the item from being sent.
'
'End Sub
'Private Sub colExplorers_NewMail() 'Notifies your program that new items have been delivered to the Inbox.
'
'End Sub
'Private Sub colExplorers_OnError() 'Notifies your program that an error occurred during folder synchronization.
'
'End Sub
'Private Sub colExplorers_OptionsPagesAdd() 'Notifies your program that new options pages have been added to a property or options dialog box.
'
'End Sub
'Private Sub colExplorers_Progress() 'Notifies your program of the status of folder synchronization.
'
'End Sub
'Private Sub colExplorers_Reminder() 'Notifies your program that a reminder is about to be displayed.
'
'End Sub
Private Sub colExplorers_SelectionChange() 'Notifies your program that the selection of items in an explorer window has changed.
MsgBox "Explorers_SelectChange."
End Sub
'Private Sub colExplorers_ShortcutAdd() 'Notifies your program that a shortcut has been added to the Outlook Bar.
'
'End Sub
'Private Sub colExplorers_SyncStart() 'Notifies your program that Outlook has begun synchronizing the user抯 folders.
'
'End Sub
'Private Sub colExplorers_SyncEnd() 'Notifies your program that Outlook has finished synchronizing the user抯 folders
'
'End Sub
Private Sub colExplorers_ViewSwitch() 'Notifies your program that the view used to display the contents of a folder in an explorer window has changed.
MsgBox "Explorers_ViewSwitch."
If lclExplorer.CurrentView = "Messages with AutoPreview" And lclExplorer.IsPaneVisible(olPreview) = True Then
lclExplorer.ShowPane olPreview, False
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -