Kann man folgendes Makro so schreiben, dass ich "on behalf of" (anstatt meine eigenen) Kontakte exportieren kann?
ActiveSheet.Range("C2:D10").Select
Sub TEST_Read_Contact_from_Outlook()
'by Ramses
'Liest alle Kontakte aus Outlook in das aktuelle Tabellenblatt
Dim myOlk As Object
Dim myOlkContact As Object
Set myOlk = CreateObject("outlook.application")
Set myOlkContact = myOlk.CreateItem(2)
'ALTERCODE: Set myOlkContact = myOlk.CreateItem(olContactItem)
Range("B3").Select
For Each myOlkContact In myOlk.GetNamespace("MAPI").GetDefaultFolder(10).Items
'ALTERCODE: For Each myOlkContact In myOlk.GetNamespace("MAPI").GetDefaultFolder( _
olFolderContacts).Items
If TypeName(myOlkContact) = "ContactItem" Then
With myOlkContact
ActiveCell.Value = .Title ' Anrede
ActiveCell.Offset(0, 1).Value = .FirstName ' Vorname
ActiveCell.Offset(0, 2).Value = .MiddleName ' WeitereVornamen
ActiveCell.Offset(0, 3).Value = .LastName ' Nachname
ActiveCell.Offset(0, 4).Value = .Suffix ' Suffix
ActiveCell.Offset(0, 5).Value = .Companies ' Firma
ActiveCell.Offset(0, 6).Value = .Department ' Abteilung
ActiveCell.Offset(0, 7).Value = .JobTitle ' Position
ActiveCell.Offset(0, 8).Value = .BusinessAddressStreet ' Straßegeschäftlich
'ActiveCell.Offset(0, 9).Value = .Business2AddressStreet ' Straßegeschäftlich2
'ActiveCell.Offset(0, 10).Value = .Business3AddressStreet ' Straßegeschäftlich3
End With
End If
ActiveCell.Offset(1, 0).Select
Next
Set myOlkContact = Nothing
Set myOlk = Nothing
End Sub
|