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

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Forum statistics

Threads
1,223,896
Messages
6,175,262
Members
452,627
Latest member
KitkatToby

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