Dear all,
I am experiencing difficulties with Excel VBA! Below is what I have typed in VBA. I want to reference the file name, body, subject and attachment to a cell if possible. Please help!
Sub Print_en_save()
Dim saveCell As Range
Dim savepathCell As Range
Set saveCell = ActiveSheet.Range("T17")
SaveAs = saveCell.Value
Set savepathCell = ActiveSheet.Range("T16")
savepath = savepathCell.Value
' Save as PDF
ChDir savepath
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
SaveAs & ".pdf", Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False
Dim OutLookApp As Object
Dim OutLookMailItem As Object
Dim myAttachments As Object
Set OutLookApp = CreateObject("Outlook.application")
Set OutLookMailItem = OutLookApp.CreateItem(0)
Set myAttachments = OutLookMailItem.Attachments
With OutLookMailItem
.To = ("T8")
.Subject = ("T19")
.Body = ("T20")
myAttachments ("T21")
.Send
End With
End Sub
I am experiencing difficulties with Excel VBA! Below is what I have typed in VBA. I want to reference the file name, body, subject and attachment to a cell if possible. Please help!
Sub Print_en_save()
Dim saveCell As Range
Dim savepathCell As Range
Set saveCell = ActiveSheet.Range("T17")
SaveAs = saveCell.Value
Set savepathCell = ActiveSheet.Range("T16")
savepath = savepathCell.Value
' Save as PDF
ChDir savepath
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
SaveAs & ".pdf", Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False
Dim OutLookApp As Object
Dim OutLookMailItem As Object
Dim myAttachments As Object
Set OutLookApp = CreateObject("Outlook.application")
Set OutLookMailItem = OutLookApp.CreateItem(0)
Set myAttachments = OutLookMailItem.Attachments
With OutLookMailItem
.To = ("T8")
.Subject = ("T19")
.Body = ("T20")
myAttachments ("T21")
.Send
End With
End Sub