expected end sub

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:

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
do you think it might be
Code:
Private Sub CommandButton1_Click()
Sub DoALLsingle()
End Sub
End Sub
you can call a sub but you can't nest it
 
Upvote 0
you have a sub, inside a sub
If Sub DoALLsingle() is something (another sub) then you need to change it to DoALLsingle or CALL DoALLsingle then the programme will step out to the other sub, run that and come back just after the call
 
Upvote 0

Forum statistics

Threads
1,215,378
Messages
6,124,604
Members
449,174
Latest member
ExcelfromGermany

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top