Adding attachment to email - Runtime error 438

Jbone697

New Member
Joined
Jun 7, 2018
Messages
15
I have this macro that email's a specific range from an actvive sheet that works perfectly until I try to add an attachment from a file path on my computer and this is where I get the 438 error. What am I doing wrong? Any help is greatly appreciated.

Code:
Sub Email_Test()

MsgBox "Email will be sent to "Blah and Blah Blah"
rspn = MsgBox("Are you sure you want to send the E-mail?", vbYesNo)
If rspn = vbNo Then Exit Sub

Sheets("TestSheet1").Unprotect Password:="123456"
' Range Selection to send
   ActiveSheet.Range("E1:G9").Select
   
' Show the envelope on the ActiveWorkbook.
   ActiveWorkbook.EnvelopeVisible = True
   
'Email Details
   With ActiveSheet.MailEnvelope
      .Introduction = ""
      '.Item.To = "Blah"
      '.Item.CC = "Blah Blah"
      .Item.Subject = "Test1" & Date
      .Attachments.Add ("where my file path goes") '<<<<438 error
      .Item.Send
   End With
   Sheets("TestSheet1").Protect Password:="123456"
End Sub
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Check if the file exists before attaching. e.g.
Code:
Dim fn$
fn="c:\temp\ken.txt"
If Dir(fn)<> "" Then .Attachments.Add(fn)
 
Upvote 0

Forum statistics

Threads
1,223,723
Messages
6,174,113
Members
452,545
Latest member
boybenqn

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