| | Awarded by Microsoft since 2005: |  |
| | VBOffice Info | | Visitors | 1390779 | | Impressions | 5095609 |
| |
|
| |
| Author: Michael Bauer | Homepage | | Date: 04.04.2007 | Accessed: 19116 | | | | Description
We are very sorry! This description is not translated yet. Anyway, please try the code as it is self-explanatory. |
Option Explicit
Private WithEvents m_Inspectors As Outlook.Inspectors
Private m_CollInsp As VBA.Collection
Private m_lNextKey As Long
Private Sub Application_Startup()
Set m_Inspectors = Application.Inspectors
Set m_CollInsp = New VBA.Collection
End Sub
Private Sub m_Inspectors_NewInspector(ByVal Inspector As Outlook.Inspector)
On Error Resume Next
Dim oInspector As cInspector
Set oInspector = New cInspector
If oInspector.Init(Inspector, CStr(m_lNextKey)) Then
m_CollInsp.Add oInspector, CStr(m_lNextKey)
m_lNextKey = m_lNextKey + 1
End If
End Sub
Friend Property Get CollInsp() As VBA.Collection
Set CollInsp = m_CollInsp
End Property
Option Explicit
Private WithEvents m_oInspector As Outlook.Inspector
Private WithEvents m_oItem As Outlook.MailItem
Private m_FirstRun As Boolean
Private m_BarCreated As Boolean
Private m_IsClosed As Boolean
Private m_sKey As String
Private Sub Class_Initialize()
m_FirstRun = True
End Sub
Private Sub Class_Terminate()
CloseInspector
End Sub
Friend Sub CloseInspector()
On Error Resume Next
If m_IsClosed = False Then
m_IsClosed = True
RemoveCommandBar
DieseOutlookSitzung.CollInsp.Remove m_sKey
Set m_oItem = Nothing
Set m_oInspector = Nothing
End If
End Sub
Private Sub CreateCommandBar()
If m_BarCreated = False Then
m_BarCreated = True
End If
End Sub
Private Function GetOutlookVersion() As Long
Select Case left$(Application.Version, 2)
Case "9.": GetOutlookVersion = 9
Case "10": GetOutlookVersion = 10
Case "11": GetOutlookVersion = 11
Case "12": GetOutlookVersion = 12
Case Else: GetOutlookVersion = 0
End Select
End Function
Friend Function Init(oInspector As Outlook.Inspector, _
sKey As String _
) As Boolean
Dim obj As Object
If Not oInspector Is Nothing Then
Set obj = oInspector.CurrentItem
If TypeOf obj Is Outlook.MailItem Then
Set m_oItem = obj
Set m_oInspector = oInspector
m_sKey = sKey
Init = True
If oInspector.IsWordMail = False Then
CreateCommandBar
End If
End If
End If
End Function
Private Sub m_oInspector_Activate()
On Error Resume Next
If m_FirstRun Then
m_FirstRun = False
CreateCommandBar
End If
End Sub
Private Sub m_oInspector_Close()
CloseInspector
End Sub
Private Sub m_oItem_BeforeDelete(ByVal Item As Object, Cancel As Boolean)
On Error Resume Next
CloseInspector
End Sub
Private Sub m_oItem_Close(Cancel As Boolean)
On Error Resume Next
If GetOutlookVersion < 10 Then
CloseInspector
Else
If m_oItem.Saved Then
CloseInspector
End If
End If
End Sub
Private Sub m_oItem_Send(Cancel As Boolean)
On Error Resume Next
CloseInspector
End Sub
Friend Sub RemoveCommandBar()
If m_BarCreated Then
m_BarCreated = False
End If
End Sub
|
| | |
| | |  | ReplyAll alerts you before unintentionally replying all, or if you are a confidential BCC recipient of the ... [more] |
| | |  | Access the master category list in the blink of an eye, share your categories in a network, get a reminder service, and ... [more] |
| | |  | SAM automatically sets the sender, signature, and folder for sent items, for instance based on the recipient ... [more] |
| | |  | OLKeeper reliably prevents users from closing their Outlook window and thus possibly missing reminders or ... [more] |
| |
|