Ok, so I would like to create a couple of distro lists in outlook 2013 from data excel sheets. I am trying to use VBA to read and excel file with names in Col A and email addresses in Col B.
I dont do VBA with outlook normally, so I researched up some code.


Const DISTLISTNAME As String = "My Dist List&quot"
Const olDistributionListItem = 7
Const olFolderContacts = 10
Sub MaintainDistList()
Dim Outlook As Object ' Outlook.Application
Dim contacts As Object ' Outlook.Items
Dim myDistList As Object ' Outlook.DistListItem
Dim newDistList As Object ' Outlook.DistListItem
Dim objRcpnt As Object ' Outlook.Recipient
Dim arrData() As Variant
Dim rng As Excel.Range
Dim numRows As Long
Dim numCols As Long
Dim i As Long

Set Outlook = GetOutlookApp
Set contacts = GetItems(GetNS(Outlook))
On Error Resume Next
Set myDistList = contacts.Item(DISTLISTNAME)
On Error GoTo 0
If Not myDistList Is Nothing Then
' delete it
myDistList.Delete
End If
' recreate it
Set newDistList = Outlook.CreateItem(olDistributionListItem)
With newDistList
.DLName = DISTLISTNAME
.Body = DISTLISTNAME
End With
' loop through worksheet and add each member to dist list
' assume active sheet
numRows = ActiveSheet.Range("A1").CurrentRegion.Rows.Count - 1
numCols = ActiveSheet.Range("A1").CurrentRegion.Columns.Count
ReDim arrData(1 To numRows, 1 To numCols)
' take header out of range
Set rng = ActiveSheet.Range("A1").CurrentRegion.Offset(1, 0).Resize(numRows, numCols)
' put range into array
arrData = rng.Value
' assume 2 cols (name and emails only)

''For i = 1 To numRows
''Set objRcpnt = Outlook.Session.CreateRecipient(arrData(i, 2))
''objRcpnt.Resolve
''newDistList.AddMember objRcpnt
''Next i


For i = 1 To numRows      'little variation on your theme ...
Set objRcpnt = Outlook.Session.CreateRecipient(arrData(i, 1) & "<" & arrData(i, 2) & ">")
'end of variation
objRcpnt.Resolve   'error here
newDistList.AddMember objRcpnt
Next i




newDistList.Save
'newDistList.Display
End Sub
Function GetOutlookApp() As Object
On Error Resume Next
Set GetOutlookApp = CreateObject("Outlook.Application")
End Function
Function GetItems(olNS As Object) As Object
Set GetItems = olNS.GetDefaultFolder(olFolderContacts).items
End Function
Function GetNS(ByRef app As Object) As Object
Set GetNS = app.GetNamespace("MAPI")
End Function

I get an error the objRcpnt.Resolve line

For i = 1 To numRows      'little variation on your theme ...
Set objRcpnt = Outlook.Session.CreateRecipient(arrData(i, 1) & "<" & arrData(i, 2) & ">")
'end of variation
objRcpnt.Resolve  'error here
newDistList.AddMember objRcpnt
Next i
After looking on MS Office site i found that you cant run somehting like this with Outlook open. Fine, I close it and try again. Same fail...but this time the password login gui for outlook opens up near simulteneously with the error box. If i type in the password it doesnt miraculously move anything along, obviously.

Is there some way to allow this code to operate while Outlook is open or to work despite the password protection issue? I am open to any way to speed up the distro-making process, because there are several, they have overlapping members, about 2-3 dozen members a piece and people change often. I need a more efficient way to handle it, so if anyone has any awesome ideas, i would appreciate it greatly.

Thanks