harrison867
New Member
- Joined
- Nov 20, 2015
- Messages
- 2
hi all, i have the following code to peform creating a pdf, then sending it to via email to someone, but i get an 'expected sub end' error messge! help please
Code:
Private Sub CommandButton1_Click()
Sub DoALLsingle()
Dim tempPDFFileName, tempPSFileName, tempPDFRawFileName As String, mypdfDist As New PdfDistiller, _
i As Integer, Mail_Object, Email_Subject, o As Variant
tempPDFRawFileName = "F:\*******sF&B\MattHarrison\christmas\xmas2015" & ActiveWorkbook.Name ' Change File Path to suit
tempPSFileName = tempPDFRawFileName & ".ps"
tempPDFFileName = tempPDFRawFileName & ".pdf"
ActiveSheet.PrintOut Copies:=1, preview:=False, ActivePrinter:="Adobe PDF", _
printtofile:=True, Collate:=True, prtofilename:=tempPSFileName
mypdfDist.FileToPDF tempPSFileName, tempPDFFileName, "bookings calendar"
Kill tempPSFileName
Set mypdfDist = Nothing
'************End of PDF section*************
'************Start of emailing code*********
Set Mail_Object = CreateObject("Outlook.Application")
With Mail_Object.CreateItem(o)
.Subject = "TEST" ' CHANGE TO SUIT
.To = "" 'CHANGE TO SUIT
.Body = "SEE ATTACHMENT" & Chr(13) & Chr(13) & "Regards," & Chr(13) & "Matt." & Chr(13) & "YOUR ADDRESS." 'Change comments to suit
.Attachments.Add tempPDFFileName
.Send
End With
MsgBox "E-mail successfully sent", 64
Application.DisplayAlerts = False
Set Mail_Object = Nothing
End Sub
End Sub
Last edited by a moderator: