whirlwind147
New Member
- Joined
- Nov 14, 2011
- Messages
- 31
Hi,
I have the following code in an excel spreadsheet which when a button is clicked it attaches the range to an email. I don't want the email to be sent without the sender viewing it but I would like the PDF that is attached to open automatically so the user can check it before sending it as I've had people send the wrong things in the past. If I change the false to true after the OpenAfterPublish section it doesn't work at all. Can somebody tell me what I have to do to make this work?
Thanks in advance!
Graham
I have the following code in an excel spreadsheet which when a button is clicked it attaches the range to an email. I don't want the email to be sent without the sender viewing it but I would like the PDF that is attached to open automatically so the user can check it before sending it as I've had people send the wrong things in the past. If I change the false to true after the OpenAfterPublish section it doesn't work at all. Can somebody tell me what I have to do to make this work?
Thanks in advance!
Graham
Code:
Sub mcrPDFQuote()
'Code to create PDF file
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:= _
"C:\Quote\" & Range("a742") & Range("a743") & ".pdf", Quality:=xlQualityStandard, IncludeDocProperties _
:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
Dim OutApp As Object
Dim OutMail As Object
Dim strTo As Range
Dim strSubject As Range
Dim strBody As Range
Dim wkSht As Worksheet
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
Set strTo = Range("a744")
Set strSubject = Range("a745")
Set strBody = Range("a740")
On Error Resume Next
With OutMail
.To = strTo
.CC = ""
.BCC = ""
.Subject = strSubject
.Body = vbNewLine & Range("a740") & vbNewLine & Range("a741")
.Attachments.Add strPath & Range("a742") & Range("A743") & ".pdf"
.display 'Change to send to go without checking
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
Kill strPath & Range("a742") & Range("a743") & ".pdf"
End Sub