Bitte um Hilfe
Ich möchte in meiner Rechnungsvorlage die Adresse aus Meinem Outlook Kontakte Verzeichnis eintragen lassen, mittels Listbox o.ä.
Anrede
Vorname Name
Strasse
PLZ Ort
ev.Tel. Nr und Fax Nr.
Vielen Dank im voraus
Sub ListBoxAusOutlook()
'
' Achtung: Der Verweis (Extras/Verweise unter VBA) auf die
' "Microsoft Outlook 9.0 Object Library" muss aktiviert sein !!!
'
Dim Verz As Object
Dim iIndx As Integer
Dim olMAPI As New Outlook.Application
Dim objItem As Object
Application.DisplayAlerts = False
Application.StatusBar = " die Adressen werden aus Outlook geholt " _
& " - das kann einen Moment dauern."
Set Verz = olMAPI.GetNamespace("MAPI").GetDefaultFolder(olFolderContacts)
UserForm1.ListBox1.ColumnCount = 7
UserForm1.ListBox1.ColumnWidths = _
"7,0 cm; 3,5 cm; 1,0 cm; 3,0 cm; 1,0 cm; 3,5 cm; 3,0 cm"
For iIndx = 1 To Verz.Items.Count
Set objItem = Verz.Items(iIndx)
With objItem
UserForm1.ListBox1.AddItem " "
UserForm1.ListBox1.List(iIndx - 1, 0) = .FirstName _
& " " & .LastName
If .BusinessAddressPostOfficeBox = "" Then
UserForm1.ListBox1.List(iIndx - 1, 1) = .BusinessAddressStreet
Else
UserForm1.ListBox1.List(iIndx - 1, 1) = .BusinessAddressPostOfficeBox
End If
UserForm1.ListBox1.List(iIndx - 1, 2) = .BusinessAddressPostalCode
UserForm1.ListBox1.List(iIndx - 1, 3) = .BusinessAddressCity
UserForm1.ListBox1.List(iIndx - 1, 4) = .CustomerID
UserForm1.ListBox1.List(iIndx - 1, 5) = .AssistantName
UserForm1.ListBox1.List(iIndx - 1, 6) = .MiddleName
End With
Next iIndx
Set objItem = Nothing
Set olMAPI = Nothing
' die ListBox nach Namen (nach nur einer, der ersten Spalte) sortieren
listbox_quick_sort 0, 6, UserForm1.ListBox1, 0, UserForm1.ListBox1.ListCount - 1
Application.DisplayAlerts = True
Application.StatusBar = False
End Sub
Sub ListBoxAusOutlook()
Dim Verz As Object
Dim iIndx As Integer
Dim olMAPI As Object
Dim objItem As Object
Set olMAPI = CreateObject("Outlook.Application")
Application.DisplayAlerts = False
Application.StatusBar = " die Adressen werden aus Outlook geholt " _
& " - das kann einen Moment dauern."
Set Verz = olMAPI.GetNamespace("MAPI").GetDefaultFolder(olFolderContacts)
UserForm1.ListBox1.ColumnCount = 7
UserForm1.ListBox1.ColumnWidths = _
"7,0 cm; 3,5 cm; 1,0 cm; 3,0 cm; 1,0 cm; 3,5 cm; 3,0 cm"
For iIndx = 1 To Verz.Items.Count
Set objItem = Verz.Items(iIndx)
With objItem
UserForm1.ListBox1.AddItem " "
UserForm1.ListBox1.List(iIndx - 1, 0) = .FirstName _
& " " & .LastName
If .BusinessAddressPostOfficeBox = "" Then
UserForm1.ListBox1.List(iIndx - 1, 1) = .BusinessAddressStreet
Else
UserForm1.ListBox1.List(iIndx - 1, 1) = .BusinessAddressPostOfficeBox
End If
UserForm1.ListBox1.List(iIndx - 1, 2) = .BusinessAddressPostalCode
UserForm1.ListBox1.List(iIndx - 1, 3) = .BusinessAddressCity
UserForm1.ListBox1.List(iIndx - 1, 4) = .CustomerID
UserForm1.ListBox1.List(iIndx - 1, 5) = .AssistantName
UserForm1.ListBox1.List(iIndx - 1, 6) = .MiddleName
End With
Next iIndx
Set objItem = Nothing
Set olMAPI = Nothing
' die ListBox nach Namen (nach nur einer, der ersten Spalte) sortieren
' listbox_quick_sort 0, 6, UserForm1.ListBox1, 0, UserForm1.ListBox1.ListCount - 1
Application.DisplayAlerts = True
Application.StatusBar = False
End Sub
Vorbereitungen treffen:
VBA-Code einfügen:
Sub ListBoxAusOutlook()
Dim Verz As Object
Dim iIndx As Integer
Dim olMAPI As Object
Dim objItem As Object
Set olMAPI = CreateObject("Outlook.Application")
Application.DisplayAlerts = False
Application.StatusBar = " die Adressen werden aus Outlook geholt " _
& " - das kann einen Moment dauern."
Set Verz = olMAPI.GetNamespace("MAPI").GetDefaultFolder(olFolderContacts)
UserForm1.ListBox1.ColumnCount = 7
UserForm1.ListBox1.ColumnWidths = "7,0 cm; 3,5 cm; 1,0 cm; 3,0 cm; 1,0 cm; 3,5 cm; 3,0 cm"
For iIndx = 1 To Verz.Items.Count
Set objItem = Verz.Items(iIndx)
With objItem
UserForm1.ListBox1.AddItem " "
UserForm1.ListBox1.List(iIndx - 1, 0) = .FirstName & " " & .LastName
If .BusinessAddressPostOfficeBox = "" Then
UserForm1.ListBox1.List(iIndx - 1, 1) = .BusinessAddressStreet
Else
UserForm1.ListBox1.List(iIndx - 1, 1) = .BusinessAddressPostOfficeBox
End If
UserForm1.ListBox1.List(iIndx - 1, 2) = .BusinessAddressPostalCode
UserForm1.ListBox1.List(iIndx - 1, 3) = .BusinessAddressCity
UserForm1.ListBox1.List(iIndx - 1, 4) = .CustomerID
UserForm1.ListBox1.List(iIndx - 1, 5) = .AssistantName
UserForm1.ListBox1.List(iIndx - 1, 6) = .MiddleName
End With
Next iIndx
Set objItem = Nothing
Set olMAPI = Nothing
Application.DisplayAlerts = True
Application.StatusBar = False
End Sub
Makro ausführen:
Fehler: „Objekt nicht gefunden“
Problem: ListBox bleibt leer
Fehler: Anwendung stürzt ab
Outlook-Kontakte in Excel importieren:
Verwendung von Add-Ins:
Kontakte in Outlook importieren:
Kontakt Outlook versenden:
Outlook Adressbuch sortieren:
Outlook eigene Visitenkarte erstellen:
1. Wie kann ich Kontakte von Excel in Outlook importieren?
Du kannst die oben beschriebene VBA-Methode verwenden, um Kontakte aus Excel in Outlook zu importieren.
2. Was ist der Vorteil der Verwendung eines Makros?
Ein Makro automatisiert den Prozess und spart Zeit, insbesondere wenn Du regelmäßig Kontakte importieren oder exportieren musst.
3. Kann ich auch Gruppen von Kontakten importieren?
Ja, Du kannst auch Kontaktgruppen in Outlook importieren, indem Du die entsprechenden Attribute im VBA-Code anpasst.
Die erweiterte Suchfunktion hilft dir, gezielt die besten Antworten zu finden
Suche nach den besten AntwortenEntdecke unsere meistgeklickten Beiträge in der Google Suche
Top 100 Threads jetzt ansehen