Print to PDF and email from Excel

kgkev

Well-known Member
Joined
Jun 24, 2008
Messages
1,291
Office Version
  1. 365
Platform
  1. Windows
I have created an invoice from a SQL data source and I plan to have it emailed as a PDF to the customer.

The bit I am stuck on is printing the PDF to a predefined location with a file name generated from the sheet.

Using Excel 2000 and attempting to do the job with CutePDF.

If I record the macro I get

Code:
    Sheets("invoice").Select
    Application.ActivePrinter = "CutePDF Writer on CPW2:"
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
        "CutePDF Writer on CPW2:", Collate:=True

So this does not see anything that happens with in the CutePDF controls.


Any ideas on the best way of solving this one?
 
Last edited:

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Upvote 0
Have you tried Google?

Could you not say that to every single poster on here?

I came to MrExcel.com because I respect the views and knowledge of the members here.

The post you refer to is over a year old. perhaps better options have surfaced since.

Currently using a sendkeys solution

Code:
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
    "CutePDF Writer on CPW2:", Collate:=True

    Newhour = Hour(Now())
    newMinute = Minute(Now())
    newSecond = Second(Now()) + 2
    filename = Sheets("Data").Range("O3").Value
    filename = filename & " - " & Sheets("Data").Range("A1").Value
    filename = filename & " - " & Sheets("Data").Range("C3").Value
    filepath = "\\ih-serv\company\invoices\" & username & ".pdf"
    
    waittime = TimeSerial(Newhour, newMinute, newSecond)
    Application.Wait waittime

    SendKeys filepath & "{ENTER}", False
    Application.Wait waittime
    SendKeys "{ENTER}", False

However this triggers my AntiVirus. Might have to look at buying Office 2007 or Acrobat.
 
Upvote 0
Could you not say that to every single poster on here?
I use it very sparingly, in fact, and it was a genuine question rather than a criticism, but it's nice to know you follow my posts so avidly! To be fair you didn't say you'd tried Google. Some people seem not to have heard of it and use the forum as their first resort. Apologies if that's not the case here.

The link I posted appeared to provide a solution in spite of its age - otherwise I wouldn't have posted it. Are you saying it doesn't work?

I did also suggest allowing CutePDF to put the file wherever it wanted, then moving it using VBA. Is that worth considering or does that not actually overcome your issue?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,849
Members
452,948
Latest member
UsmanAli786

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