I have the following code with I tried to adapt from Ron De Bruin to email selected ranges as a PDF file, but I get a compile error and the code below is highlighted
FileName = RDB_Create_PDF
Mail from Excel with Outlook (VBA)
Your asistance in resolving this is most appreciated
FileName = RDB_Create_PDF
Mail from Excel with Outlook (VBA)
Your asistance in resolving this is most appreciated
Code:
Sub Mail_Report_PDF()
Sheets(1).Select
With Range("D:R,M:S,X:AJ,BA:BJ,BM:BR,BU:CH")
.EntireColumn.Hidden = True
End With
Dim FileName As String
If ActiveWindow.SelectedSheets.Count > 1 Then
MsgBox "There is more then one sheet selected," & vbNewLine & _
"ungroup the sheets and try the macro again"
Else
'Call the function with the correct arguments
'For a fixed range use this line
FileName = RDB_Create_PDF(Source:=Range("Man_Report1", "MAN_Report2"), _
FixedFilePathName:="", _
OverwriteIfFileExist:=True, _
OpenPDFAfterPublish:=False)
'For the selection use Selection in the Source argument
'FileName = RDB_Create_PDF(Source:=Selection)
'For a fixed file name use this in the FixedFilePathName argument
'FixedFilePathName:="C:\Users\Ron\Test\YourPdfFile.pdf"
If FileName <> "" Then
RDB_Mail_PDF_Outlook FileNamePDF:=FileName, _
StrTo:="Mark@davidsonsn@Gm,ail.com", _
StrCC:="", _
StrBCC:="", _
StrSubject:="Management Reports", _
Signature:=True, _
Send:=False, _
StrBody:="<H3><B>Dear Sirs l</B></H3><br>" & _
"<body>See Attached Management Reports in PDF." & _
"<br><br>" & "Regards</body>"
Else
MsgBox "Not possible to create the PDF, possible reasons:" & vbNewLine & _
"Microsoft Add-in is not installed" & vbNewLine & _
"You Canceled the GetSaveAsFilename dialog" & vbNewLine & _
"The path to Save the file in arg 2 is not correct" & vbNewLine & _
"You didn't want to overwrite the existing PDF if it exist"
End If
End If
End Sub