Here is my code I got to work, however I have multiple excel files at a time.
How do I not open the excel doc to run and add a loop to repeat the process for all files in the folder?
The MSG piece is critical and there is specific information needed in the body, can I add on to this? I understand VB enough, but not enough to figure the rest of this out.
Thanks
Angela
CODE
------------------------------------------------------------------
Sub PDFEmail()
'Declare variables
Dim MyFilePath As String
Dim MyFileName As String
Dim OutlookApp As Outlook.Application
Dim MItem As Outlook.MailItem '<-- Early binding
Dim EmailAddress As String
Dim EmailSubject As String
Dim Msg As String
Application.ScreenUpdating = False
'Activate the Transaction Form worksheet
'Worksheets("Transaction Form").Activate
'Specify email address, email subject, and a brief message
EmailAddress = "Angela.Matthey@adidas.com"
EmailSubject = "Please see attached email"
Msg = Range("A2")
'Build parts of name of PDF file
MyFilePath = "C:\Users\matthane\Documents\OLD_ECOM_DATA\Missing"
'ThisWorkbook.Path & "C:\Users\matthane\Documents\OLD_ECOM_DATA\Missing"
MyFileName = ActiveSheet.Name
'Save Transaction Form as PDF file in same directory as this
'Excel workbook
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
MyFilePath & MyFileName, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
False
'Create Outlook object
Set OutlookApp = New Outlook.Application
'Send out the email
Set MItem = OutlookApp.CreateItem(olMailItem)
With MItem
.To = EmailAddress
.Subject = EmailSubject
.Body = Msg
.Attachments.Add MyFilePath & MyFileName & ".PDF"
.Send
End With
'House cleaning
Set OutlookApp = Nothing
MsgBox "Email has been sent. BTW Your coffee and danish are waiting downstairs."
Application.ScreenUpdating = True
End Sub
Bookmarks