Gruppe
Extern
Problem
Im Outlook-Adressbuch soll der in Zelle B1 eingetragene Name gesucht und das Ergebnis der Suche in einer MessageBox angezeigt werden.
StandardModule: Modul1
Sub NameExists()
Dim oOL As Object
Dim oAdr As Object
Dim oEntry As Object
Dim iCounter As Integer
Dim bln As Boolean
bln = Application.DisplayStatusBar
Application.DisplayStatusBar = True
Set oOL = CreateObject("Outlook.Application")
Set oAdr = oOL.Session.AddressLists("Kontakte")
For Each oEntry In oAdr.AddressEntries
If iCounter Mod 10 = 0 Then
Application.StatusBar = _
"Prüfe Adresse Nr. " & iCounter & "..."
End If
If Range("B1").Value = oEntry.Name Then
MsgBox "Adresse wurden gefunden!"
GoTo FINISH
End If
iCounter = iCounter + 1
Next oEntry
MsgBox "Name wurde nicht gefunden!"
FINISH:
Set oOL = Nothing
Application.StatusBar = False
Application.DisplayStatusBar = bln
End Sub