Forum Discussion
Joe Gray
May 30, 2017Copper Contributor
Re: Macro to save as PDF with auto filename as cell value
Hi I recently used the following Macro, provided by Gary's Student, to create a PDF from an active sheet, generate a unique Filename based on a cell ref and save it to a specific location. This m...
Andrew Jones
Jun 02, 2017Copper Contributor
This is code I use.
End Sub
Private Sub Email()
Dim objOutlook As Object
Dim objMail As Object
Dim signature As String
Dim oWB As Workbook
Set oWB = ActiveWorkbook
Set objOutlook = CreateObject("Outlook.Application")
Set objMail = objOutlook.CreateItem(0)
With objMail
.Display
End With
signature = objMail.HTMLbody
With objMail
.To = oWB.Sheets("Sheet1").Range("A1").Value
''.SentOnBehalfOfName = ""
.Subject = strMySubject
''.body = "Dear Sir," & vbNewLine & vbNewLine & "Add stuff here" & vbNewLine & vbNewLine & signature
.HTMLbody = "<font face=" & Chr(34) & "Calibri" & Chr(34) & " size=" & Chr(34) & 4 & Chr(34) & ">" & "Dear Sir," & "<br> <br>" & "Add stuff here" & "<br> <br>" & signature & "</font>"
.Attachments.Add (strSaveFileName + ".pdf")
.Display
End With
Set objOutlook = Nothing
Set objMail = Nothing
End SubJoe Gray
Jun 02, 2017Copper Contributor
Thank you Andrew
You‘re no doubt aware that I am new to Coding and very much appreciate your response. I will hopefully be able to pass on assistance to others in the very near future.