I read the following to simply select a distribution list I received, and then run this macro that creates a contact for each one in the distribution list.....but it saves all the contacts to the Contact folder...so can I change it to save them to a subfolder under the Contact folder?
Sub CreateContactsfromDL()
Dim o_list As Object
Dim objContact As outlook.contactItem
' set your category here.
t_cat = "From DL"
' Current object and should be the distributionlist
Set o_list = GetCurrentItem()
For i = 1 To o_list.MemberCount
' Create separate contacts
Set objContact = Application.CreateItem(olContactItem)
With objContact
.Email1Address = o_list.GetMember(i).Address
.FullName = o_list.GetMember(i)
.Categories = t_cat
.Save
End With
Next
Set objContact = Nothing
Set o_list = Nothing
End Sub
Function GetCurrentItem() As Object
Dim objApp As outlook.Application
Set objApp = Application
On Error Resume Next
Select Case TypeName(objApp.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = objApp.ActiveInspector.currentItem
End Select
Set objApp = Nothing
End Function
Sub CreateContactsfromDL()
Dim o_list As Object
Dim objContact As outlook.contactItem
' set your category here.
t_cat = "From DL"
' Current object and should be the distributionlist
Set o_list = GetCurrentItem()
For i = 1 To o_list.MemberCount
' Create separate contacts
Set objContact = Application.CreateItem(olContactItem)
With objContact
.Email1Address = o_list.GetMember(i).Address
.FullName = o_list.GetMember(i)
.Categories = t_cat
.Save
End With
Next
Set objContact = Nothing
Set o_list = Nothing
End Sub
Function GetCurrentItem() As Object
Dim objApp As outlook.Application
Set objApp = Application
On Error Resume Next
Select Case TypeName(objApp.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = objApp.ActiveInspector.currentItem
End Select
Set objApp = Nothing
End Function