Results 1 to 3 of 3

Thread: How to create Outlook Distribution lists in Excel VBA

  1. #1
    Join Date
    Nov 2011

    How to create Outlook Distribution lists in Excel VBA

    I manage a list of several committees within my group at work and each group has anywhere from 2 to 40 members. Each person is on 3 to 5 committees. I want to create a macro that can easily create Outlook distribution lists since people keep joining my group and people can always change committee preferences. I have already created a macro that scrolls through the committee matrix and creates a string for each committee with all the members included. The string is composed of the names (copied from the Outlook directory) separated by a semi-colon (ie. Summer, Kyle; Lindy, Maria; Sampson, Oscar). This way, I can just copy the cell and manually create a distribution list in outlook, click on add members, and all I have to do is paste the list as opposed to individually adding each member.

    I would like to expand it so it actually creates the distribution lists automatically and either saves them in my Outlook contacts or saves them to the desktop or my documents so you can simply drag them into Outlook. That would probably be the easiest way as it would then prompt you if you want to overwrite existing distribution lists with the same names. I have found pieces of code scattered across the internet, but I get errors when the VBA is simply compiling.

  2. #2
    Join Date
    Jul 2011

    Re: How to create Outlook Distribution lists in Excel VBA

    Below is an example of a subroutine that looks across row 1 and creates distribution lists for each of the names found in those cells in the Outlook Contacts folder. You need to go to 'Tools > References' and set a reference to the Outlook library for the version of Office you have.
    Sub MakeOLdistrList()
    Dim olApp As Outlook.Application
    Dim myDistList As Outlook.DistListItem
    Set olApp = New Outlook.Application
    colCount = ActiveSheet.UsedRange.Columns.Count
    For C = 1 To colCount
    Set myDistList = olApp.CreateItem(olDistributionListItem)
    With myDistList
    .DLName = Cells(1, C).Value
    End With
    Next C
    Set olApp = Nothing
    End Sub

  3. #3
    Join Date
    Jul 2011

    Re: How to create Outlook Distribution lists in Excel VBA

    Below is the example from VBA help that shows how to add members. I don't find it intuitive but it is the way it is.
    Sub AddNewMembers()
    Dim myOlApp As New Outlook.Application
    Dim myNameSpace As Outlook.NameSpace
    Dim myDistList As Outlook.DistListItem
    Dim myTempItem As Outlook.MailItem
    Dim myRecipients As Outlook.Recipients
    Set myNameSpace = myOlApp.GetNamespace("MAPI")
    Set myDistList = myOlApp.CreateItem(olDistributionListItem)
    Set myTempItem = myOlApp.CreateItem(olMailItem)
    Set myRecipients = myTempItem.Recipients
    myDistList.DLName = _
    InputBox("Enter the name of the new distribution list")
    myRecipients.Add myNameSpace.CurrentUser.Name
    myRecipients.Add "Dan Wilson"
    myDistList.AddMembers myRecipients
    End Sub

Similar Threads

  1. How to find total number of duplicates from lists of sheet in excel
    By Kungfu Pandey in forum MS Office Support
    Replies: 2
    Last Post: 08-01-2012, 04:51 PM
  2. Mass deletion of distribution lists via AD
    By SimonH in forum Windows Software
    Replies: 1
    Last Post: 06-10-2011, 02:35 PM
  3. Find Empty Distribution Lists
    By Khongordzol in forum Active Directory
    Replies: 3
    Last Post: 24-09-2010, 06:15 PM
  4. How to create a distribution list in Outlook
    By SpearMan in forum Tips & Tweaks
    Replies: 1
    Last Post: 18-02-2009, 02:54 PM
  5. Distribution Groups - export lists and members
    By Isaivalan in forum Active Directory
    Replies: 2
    Last Post: 24-07-2007, 11:30 AM

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Page generated in 1,642,871,950.76174 seconds with 17 queries