Macro to automatically run Primo pdf

beeman

New Member
Joined
Jun 1, 2011
Messages
17
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>
<o:p> </o:p>
I am looking for a macro that can be link to a button that will automatically load and convert a document using PrimoPDF converter. I would like it to load Primo PDF and attached the new pdf file to an email. The code I have so far will open Primo PDF and reset the printers back to normal but wont continue on to automatically convert it and attach it to an email. I will be using this alot and would like to cut out a few steps if I can.
<o:p> </o:p>
Sub PDF_Converter()<o:p></o:p>
'<o:p></o:p>
' PDF_Converter Macro<o:p></o:p>
'<o:p></o:p>
ActivePrinter = "PrimoPDF"<o:p></o:p>
Application.PrintOut FileName:="", Range:=WdPrintAllDocument, Item:= _<o:p></o:p>
wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _<o:p></o:p>
ManualDuplexPrint:=False, Collate:=True, Background:=False, PrintToFile:= _<o:p></o:p>
False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _<o:p></o:p>
PrintZoomPaperHeight:=0<o:p></o:p>
ActivePrinter = "Backprinter"<o:p></o:p>
End Sub
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
I know this is an old post, but this is the solution I came up with that uses Cute PDF. All you have to do is put in the proper filepath in the code and click yes when it tries to automatically email. There is a program called Express Click Yes that automatically clicks the yes on those prompts as well. One click save to pdf and email.
Code:
Sub SavePDF()

pdf = "your filepath" & ".pdf"

Application.ScreenUpdating = False

If Range("E8").Value = "" Then
MsgBox ("Please select an invoice before attempting to save.")
Exit Sub
Else

'saves last used printer to pass control back to
defaultPrinter = Application.ActivePrinter
'Check to see if file already exist, if so deletes it so new file can be saved
    If FileFolderExists(pdf) Then
    Kill (pdf)
    Else
    End If

'uses Cute PDF Writer to save a copy
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"CutePDF Writer on CPW2:", Collate:=True
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 4
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
Filename = pdf
SendKeys Filename & "{ENTER}", True

'gives control back to last used printer
Application.ActivePrinter = defaultPrinter

End If
Application.ScreenUpdating = True
End Sub
Sub SavePrintInvoice()
Application.ScreenUpdating = False

'Prints out on last used printer
ActiveWindow.SelectedSheets.PrintOut

'Saves to PDF
Call SavePDF

Application.ScreenUpdating = True
End Sub
Sub emailInvoice()

newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 4
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime

pdf = "your filepath" & ".pdf"

'emails a copy as an attachment
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
body = Worksheets("Invoice").Range("AN19").Value

On Error Resume Next
With OutMail
.To = "" 'put the desired email addresses within the quotes
.CC = ""
.BCC = ""
.Subject = ""
.body = body
.Attachments.Add pdf
.Send

End With
On Error GoTo 0

Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Sub SaveEmailInvoice()
Application.ScreenUpdating = False

'Saves to PDF
Call SavePDF

'Emails Invoice
Call emailInvoice

Application.ScreenUpdating = True

End Sub
Sub SavePrintEmailInvoice()
Application.ScreenUpdating = False

'Prints out on last used printer
ActiveWindow.SelectedSheets.PrintOut

'Saves to PDF
Call SavePDF

'Emails Invoice
Call emailInvoice

Application.ScreenUpdating = True
End Sub
I found this post while trying to search for a way to use Primo PDF instead, one of our employees' computer doesn't play nice with Primo PDF for some reason.
 
Upvote 0

Forum statistics

Threads
1,224,561
Messages
6,179,521
Members
452,923
Latest member
JackiG

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