VBA objDistList.DLName causing error

jscranton

Well-known Member
Joined
May 30, 2011
Messages
707
I am trying to create an Outlook distribution group from a list of emails in Excel. All the examples I have found use this line to set the distrolist name:


objDistList.DLName = "Whatever"

However, it is throwing a Run-time error 438 "Object doesn't support this property or method"

Suggestions?


Code:
Public Sub DistributionList()


Dim objOutlook As Object
Dim objNameSpace As Object
Dim objDistList As Object
Dim objMail As Object
Dim objRecipients As Object


Set objOutlook = CreateObject("Outlook.Application")
Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set objDistList = objOutlook.CreateItem(olDistributionListItem)
Set objMail = objOutlook.CreateItem(olMailItem)
Set objRecipients = objMail.Recipients
objDistList.DLName = "Whatever"
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Mail item type variables belong to Outlook namespace - they are not initialized in Excel namespace. You need to initialize them before you use them.
Add these two assignment lines in your code after declaration of variables:

Code:
olDistributionListItem = 7
olMailItem = 0
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,116
Messages
6,128,926
Members
449,479
Latest member
nana abanyin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top