Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving CutePDF Writer files 1

Status
Not open for further replies.

rj51cxa

Technical User
Mar 16, 2006
216
GB
I have a command button which prints a series of reports to CutePDF. This work fine but each time a pdf file is created, a box appears asking me where I want to save it. Is there a way of adding a line to my code which does this automatically?

The code I have looks like this:

Code:
Private Sub CreatePDF_Click()
On Error GoTo Err_CreatePDF_Click

Dim prtDefault As Printer

Set Application.Printer = Application.Printers("CutePDF Writer")

Set prtDefault = Application.Printer

    Dim stDocName1 As String
    Dim stDocName2 As String
    Dim stDocName3 As String
                
    stDocName1 = "RptRobertsInd"
    stDocName2 = "RptRobertsTeam"
    stDocName3 = "RptRoupellInd"
        
    DoCmd.OpenReport stDocName1, acNormal
    DoCmd.OpenReport stDocName2, acNormal
    DoCmd.OpenReport stDocName3, acNormal
 
Set Application.Printer = Application.Printers("HP Laserjet 1020")

Set prtDefault = Application.Printer
 
Exit_CreatePDF_Click:
    Exit Sub

Err_CreatePDF_Click:
    MsgBox Err.Description
    Resume Exit_CreatePDF_Click
    
End Sub

Best Regards
John
 
The easy solution is to use a PDF printer that can be set to save directly to a file.

You might have a little trouble finding it but the GNU version (there is also a newer commercial version that you have to pay for) of PDFCreator works well... It is a little counterintuitive at first but works.

You also need to rearrange two lines of code otherwise you won't set the printer back to the original pritner.

Code:
Set prtDefault = Application.Printer

Set Application.Printer = Application.Printers("CutePDF Writer")
 
Thanks Lameid, I know that CutePDF has a Custom version which will do what I want, but that is really expensive ($400+). Considering that I only need this two or three times a month, its not worth it. I'll have a look at PDF Creator and see if it will help. Otherwise, I guess I'll just have to live with the file saving dialog box.

As far as re-setting the default printer is concerned, I have that at the end of the code, I just left it out in order to save sapce.

Huggyboy,

I looked at your "ramblings" and I can see what you are getting at but I can't see how it would fit into my coding. If you can find time to amend my code, I would be most grateful.

Thanks to everyone
John
 
Lameid and Huggyboy

I have downloaded the free version of PDF Creator and this does exactly what I want. I can now click on my Create PDF command button and all the reports in the list are automatically saved into a file on my desktop. I still have a problem with combining them, but that can be sorted out later.

Huggyboy, please don't spend any of your valuable time on modifying my code. I have a system that works, so its best left alone.

Thank you both for your help, it was much appreciated.
Best Regards
John
 
ah - I see what you mean - the example was written in vb.net!!! - i use both in my job
The principle still applies though - ie waiting for the pdf printer to finish in the background.

Glad you have fixed your problem.
H
 
rj51cxa,

You can set PDF Creator to collect files instead of print to a file.

Then after your done 'printing' you'd have to go into it, and on the toolbar there is a button for combining and another for finishing the print to file... Unfortuantely I don't have it in front of me and I'm going off of almost a year old memory.

Also worth mentioning is that Access 2007 prints to PDF via a free add-in available from Microsoft. I expect you are using an earlier version anyways but others might find that useful.
 
Thanks again to both of you for your help. I got PDF Creator working but I didn't like the combining part and, as I already had PDF995, I decided to use the combining part of that. Its very similar to Adobe and very easy to use.

At the end of the day, I have solved my problem and can do what I wanted to do.

Best Regards
John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top