Run-Time Error '438' when populating e-mail addresses from within Excel VBA

saltire1963

Board Regular
Joined
Aug 11, 2014
Messages
69
Tried researching this error I get when running my file, it says "Object doesn't support this property or method", however it doesn't point to which object is causing the issue. I am basically trying to populate an Outlook e-mail with e-mail addresses that I loop through in Column A .


VBA Code:
Dim EmailApp As Outlook.Application 'To refer to outlook application
    Dim EmailItem As Outlook.MailItem 'To refer new outlook email
    Dim EmailAddr As String
    Dim LastRow As Long
    Dim cell As Range

    Application.EnableEvents = False
    Application.ScreenUpdating = False
  
    Set EmailApp = New Outlook.Application 'To launch outlook application
    Set EmailItem = EmailApp.CreateItem(olMailItem) 'To launch new outlook email

    'Find last row in Column A
    LastRow = Sheets("Players").Cells(Rows.Count, 1).End(xlUp).Row
  
    Set cell = Range("A1:A" & LastRow)
  
    With Sheets("Players")
        For Each cell In Range("A1:A" & LastRow)
            If cell.Value Like "*@*" Then
                EmailAddr = EmailAddr & ";" & cell.Value
            End If
        Next
    End With

    With Sheets("Players")
        .Attachments.Add ActiveWorkbook.FullName, , , ActiveWorkbook.Name
        .Display
    End With

    Application.EnableEvents = True
    Application.ScreenUpdating = True
 
Last edited by a moderator:

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
With Sheets("Players")
.Attachments.Add ActiveWorkbook.FullName, , , ActiveWorkbook.Name
.Display
End With
Here you are referring to Sheets("Players").Attachments.Add which isn't right, should be:
VBA Code:
With EmailItem
    .Attachments.Add ActiveWorkbook.FullName, , , ActiveWorkbook.Name
    .Display
End With
 
Upvote 0
Solution

Forum statistics

Threads
1,223,882
Messages
6,175,164
Members
452,615
Latest member
bogeys2birdies

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