How to have Attachments based on a cell value VBA.

vba_tester

New Member
Joined
Mar 17, 2019
Messages
2
I'm currently trying to have the VBA running that will send the current files based on excel cells.

I have a message error on the line :
myAttachments.ADD "Sheet3.Cells(9, 2)"

The cell B,9 currently have the following value :
C:\Users\ojodoin\Desktop\Feuilledetemps.pdf

which is where I want to get the files for my email. Again, I know I can wrote it manually directly in the VBA , but I don't want this. (multiple users )

This is my actual
HTML:
Sub Stest()
Dim myFolder As String
ldress = Sheet3.Cells(6, 2)

ChDir ldress
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="Feuilledetemps"

Dim OutLookapp As Object
Dim OutLookMailItem As Object
Dim myAttachements As Object
Dim edress As String

Set OutLookapp = CreateObject("Outlook.application")
Set OutLookMailItem = OutLookapp.CreateItem(0)
edress = Sheet3.Cells(5, 2)

Set myAttachments = OutLookMailItem.Attachments

With OutLookMailItem.
To = edress.
Subject = "Feuille de temps"
myAttachments.ADD "Sheet3.Cells(9, 2)"   
.Display   
End With

Set OutLookMailItem = Nothing
Set OutLookapp = Nothing

End Sub
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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