I am trying to create a a button via insert shape, and then assign a module to that shape when clicked. The goal is to send just a predetermined set of cells as a pdf via outlook. Here is what I am currently inserting, and it is not working. Clearly. I have the print area set to A1:I110. Ideally, I could just code the module to read that set of cells, rather than print area. Email address of client is on the same sheet as a cell. Any help is appreciated. New to this.
VBA Code:
Sub RectangleRoundedCorners1_Click()
Public Sub Send_Email_For_Print_Area()
Dim destFolder As String, PDFfile As String
Dim printRange As Range
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Set OutApp = New Outlook.Application
'PDF file for print range is temporarily saved in same folder as this workbook
destFolder = ThisWorkbook.Path & "\"
If Right(destFolder, 1) <> "\" Then destFolder = destFolder & "\"
If ActiveSheet.PageSetup.PrintArea <> "" Then
'Save print area for active sheet as a PDF file, file name from cell C6
PDFfile = destFolder & ActiveSheet.Range("B10").Value & ".pdf"
Set printRange = Range(ActiveSheet.PageSetup.PrintArea)
printRange.ExportAsFixedFormat Type:=xlTypePDF, Filename:=PDFfile, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
'Send email to address in cell B15 of active sheet with PDF file attached
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = ActiveSheet.Range("B15").Value
.Subject = ActiveSheet.Range("C6").Value
.Body = "Please see attached PO. We look forward to your response and collaboration. Do not hesitate to reach out with any questions. Thank you."
.Attachments.Add PDFfile
.send
End With
'Delete the temporary PDF file
Kill PDFfile
Set OutMail = Nothing
Set OutApp = Nothing
End If
End Sub
End Sub