willow1985
Well-known Member
- Joined
- Jul 24, 2019
- Messages
- 888
- Office Version
- 365
- Platform
- Windows
I have the below code that converts and saves 2 worksheets to pdfs and then creates an email.
What I would like to add is code that attaches every document from column C from its corresponding directory in column D.
Column C and D may change (become longer or shorter) depending on what files the user wants to attach.
Any help with modifying this code would be greatly appreciated.
What I would like to add is code that attaches every document from column C from its corresponding directory in column D.
Column C and D may change (become longer or shorter) depending on what files the user wants to attach.
Any help with modifying this code would be greatly appreciated.
OPS 068 Rev 17 and OPS 069 Rev 17.xlsm | ||||||
---|---|---|---|---|---|---|
A | B | C | D | |||
1 | Customer: | E Metals | Documents to Attach | Directories | ||
2 | Contact: | Carole Smith | WTC amo.pdf | X:\ADMINISTRATION\QAEng\Carla's Documents\Project\ | ||
3 | Email: | Carole.Smith@notreal.com | WTC comp.pdf | X:\ADMINISTRATION\QAEng\Carla's Documents\Project\ | ||
4 | ISO TRC.pdf | X:\ADMINISTRATION\QAEng\Carla's Documents\Project\ | ||||
5 | RC Wpg.pdf | X:\ADMINISTRATION\QAEng\Carla's Documents\Project\ | ||||
6 | RR Wpg.pdf | X:\ADMINISTRATION\QAEng\Carla's Documents\Project\ | ||||
7 | RRT Wpg.pdf | X:\ADMINISTRATION\QAEng\Carla's Documents\Project\ | ||||
8 | OPS 068.pdf | X:\ADMINISTRATION\QAEng\Carla's Documents\Project\ | ||||
9 | OPS 069.pdf | X:\ADMINISTRATION\QAEng\Carla's Documents\Project\ | ||||
Input |
VBA Code:
Sub Email()
'
' Email Macro
'
Dim Path As String
Dim filename As String
Path = Sheets("Input").Range("D8")
filename = Sheets("Input").Range("C8")
Sheets("OPS 068").Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, filename:=Path & filename & ".pdf", Quality:=xlQualityStandard, _
IncludeDocProperties:=False, IgnorePrintAreas:=False, OpenAfterPublish:=True
Dim Path2 As String
Dim filename2 As String
Path2 = Sheets("Input").Range("D9")
filename2 = Sheets("Input").Range("C9")
Sheets("OPS 069").Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, filename:=Path2 & filename2 & ".pdf", Quality:=xlQualityStandard, _
IncludeDocProperties:=False, IgnorePrintAreas:=False, OpenAfterPublish:=True
'
Sheets("Input").Select
Dim outlookApp As Object, MItem As Object
Set outlookApp = CreateObject("Outlook.Application")
Set MItem = outlookApp.CreateItem(0)
With MItem
.To = Sheets("Input").Range("B3")
.Subject = "Supplier Survey"
.Body = "Good Afternoon " & Sheets("Input").Range("B2") & vbCrLf & vbCrLf & "Please find attached our documents." & vbCrLf & vbCrLf & "Please let us know if you require anything further"
.Display
End With
End Sub