I have the code below but at the Filters line it gives me an error of Complie Error: Argument not optional
Any help with this would be very welcome
Thanks for looking
Code:
Sub create_and_email_pdf()
Dim EmailSubject As String, EmailSignature As String
Dim CurrentMonth As String, DestFolder As String, PDFFile As String
Dim Email_To As String, Email_CC As String, Email_BCC As String
Dim OpenPDFAfterCreating As Boolean, AlwaysOverwritePDF As Boolean, DisplayEmail As Boolean
Dim OverwritePDF As VbMsgBoxResult
Dim OutlookApp As Object, OutlookMail As Object
Dim fullpath As String
Dim Cn As Variant
EmailSubject = "Quotation Attached"
OpenPDFAfterCreating = False
AlwaysOverwritePDF = False
DisplayEmail = True
'Email_To = 'Sheets("Quotation").Range("I1") 'Change this if you want to specify To email e.g. ActiveSheet.Range("H1") to get email from cell H1
Email_CC = ""
Email_BCC = ""
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = False
.InitialFileName = Environ$("OneDrive") & "\MJM Services\2.0 Quotations\pdf Copy\"
.Title = "Select the file to email"
.Filters.Add " *.pdf"
If .Show <> -1 Then Exit Sub
fullpath = .SelectedItems.Item(1)
End With
Set OutlookApp = CreateObject("Outlook.Application")
Set OutlookMail = OutlookApp.CreateItem(0)
With OutlookMail
.Display
.To = Email_To
.CC = Email_CC
.BCC = Email_BCC
.Subject = EmailSubject
.Attachments.Add PDFFile
If DisplayEmail = False Then
.Send
End If
End With
End Sub
Any help with this would be very welcome
Thanks for looking