brianfosterblack
Active Member
- Joined
- Nov 1, 2011
- Messages
- 251
I have this code to save the invoice in my Excel spreadsheet as a pdf document
This code then attaches the document to the mail when I send it
It works perfectly but obviously if someone else uses the workbook the directory changes
The Entries Workbook and Entries.pdf will always be in the same directory
Is there a way to change this code that it saves the pdf to the same directory the workbook is in (the workbook from which this code is being run)
And then picks up the attachment from the same directory?
VBA Code:
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\Users\User\Documents\Clay\2021 SA Grand\Entries.pdf", Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
VBA Code:
emailItem.Attachments.Add ("C:\Users\User\Documents\Clay\2021 SA Grand\Entries.pdf")
It works perfectly but obviously if someone else uses the workbook the directory changes
The Entries Workbook and Entries.pdf will always be in the same directory
Is there a way to change this code that it saves the pdf to the same directory the workbook is in (the workbook from which this code is being run)
And then picks up the attachment from the same directory?