modOutlSubs (Die wichtigsten Grundlagen zur VBA-Steuerung von Outlook)

 

Option Compare Database
Option Explicit

Public objOutlApp As Outlook.Application
Function InitOutlook() As Boolean

On Error Resume Next
InitOutlook = False ‚Default: Keine Verbindung
Set objOutlApp = GetObject(, „Outlook.Application“)
If Err <> 0 Or objOutlApp Is Nothing Then
Err = 0
Set objOutlApp = CreateObject(„Outlook.Application“)
If Err <> 0 Or objOutlApp Is Nothing Then
Beep
MsgBox „Verbindung zu Outlook kann nicht aufgebaut werden: “ & _
Err.Description, vbOKOnly + vbCritical, „Problem:“
Exit Function
End If ‚Err<> 0…
End If ‚Err<> 0…

InitOutlook = True

End Function

Function ResetOutlook() As Boolean

On Error Resume Next
ResetOutlook = False ‚Default: Keine Verbindung
If Not objOutlApp Is Nothing Then
Set objOutlApp = Nothing
ResetOutlook = True
End If

End Function