Here is the Correct Code!
There are also some more functions in there so don't wonder.
Sub All_to_PDF_File()
Dim Filename As String
Dim sFile As String, sPath As String
Dim wBook As Workbook
Dim x As Long
Dim y As Long
On Error Resume Next
Set wBook = Workbooks("Purchase Order Details for FY 2015.xlsx")
If wBook Is Nothing Then 'Not open
MsgBox "Please Open 'Purchase Order Details for FY 2015.xlsx' before running this macro!!"
Set wBook = Nothing
On Error GoTo 0
Else 'It is open
Workbooks("Purchase Order Details for FY 2015.xlsx").Activate
Worksheets("2015").Select
With ActiveSheet
y = .Cells(.Rows.Count, "C").End(xlUp).Row
End With
Range("B" & y + 1).Select
Selection.Copy
Workbooks("Technology Purchase Order Template V4.xlsm").Activate
Worksheets("PO Authorization").Select
Range("B5").Select
ActiveSheet.Paste
Workbooks("Technology Purchase Order Template V4.xlsm").Activate
Worksheets("SBB").Select
Range("A2:W2").Select
Selection.Copy
Workbooks("Purchase Order Details for FY 2015.xlsx").Activate
Worksheets("2015").Select
With ActiveSheet
x = .Cells(.Rows.Count, "C").End(xlUp).Row
End With
Range("C" & x + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues
Workbooks("Technology Purchase Order Template V4.xlsm").Activate
Worksheets("PO Authorization").Select
'Call the function with the correct arguments
Filename = RDB_Create_PDF(ActiveWorkbook, "", True, True)
'For a fixed file name and overwrite it each time you run the macro use
'RDB_Create_PDF(ActiveWorkbook, "C:\Users\Ron\Test\YourPdfFile.pdf", True, True)
If Filename <> "" Then
'Ok, you find the PDF where you saved it
'You can call the mail macro here if you want
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