Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Printing MS-Access-Report to PDF without Save-As-Dialogbox

Posted on 2004-10-18
8
Medium Priority
?
1,327 Views
Last Modified: 2013-12-02
Although this theme has already been discussed I have still no soution found for my problem.
I use WindowsXP with SP2, MS Office Prof 2000 and have installed Acrobat 6.0 Prof. (full version). Now I want to print the report from my Access-application to the PDF-Writer. Therefore I entered in the Registry the key which holds the desired filename and another key with the bDocInfo containing a zero. But every time I want to print the report will be generated but I am asked for the filename. In the meantime I did visit a lot of interesting internet pages but without success. It seems that Adobe has made serious changes in his PDF-Writer so the examples I found are now no more working.

The code is as follows:
    'Save current default printer
    sMyDefPrinter = bGetRegValue(HKEY_CURRENT_USER, "Software\Microsoft\WIndows NT\CurrentVersion\Windows", "Device")
   
    ' Set default printer to PDF Writer
    bSetRegValue HKEY_CURRENT_USER, "Software\Microsoft\Windows NT\CurrentVersion\Windows", "Device", "Adobe PDF"

    'Setting value for PDFFileName in the registry stops file dialog box from appearing
    bSetRegValue HKEY_CURRENT_USER, "Software\Adobe\Adobe PDF", "PDFFileName", sPDFPath + sPDFName
    bSetRegValue HKEY_CURRENT_USER, "Software\Adobe\Adobe PDF", "bDocInfo", 0

    DoCmd.OpenReport rptName, acViewNormal

    ' Restore default printer
    bSetRegValue HKEY_CURRENT_USER, "Software\Microsoft\WIndows NT\CurrentVersion\Windows", "Device", sMyDefPrinter

While running the program the entries in the registry are be done, printer switches to Adobe but the File Save Dialog Box still appears!

Any suggestions? Any help?
Thanks a lot for your comments.
Traindog

0
Comment
Question by:Traindog
8 Comments
 
LVL 27

Expert Comment

by:jjafferr
ID: 12342262
Hi Traindog,

Have a look here:
http://www.experts-exchange.com/Databases/MS_Access/Q_21078898.html

I hope this helps,

jaffer
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 12342593
You should be able to alter the properties of the PDF printer to bypass the save dialog (open the printer and go Printer->Properties), but this is another reason I no longer use Acrobat.
0
 
LVL 52

Accepted Solution

by:
Gustav Brock earned 336 total points
ID: 12345665
If you don't insist on using Adobe, you may wish to study FreePDF:

  http://freepdfxp.de/fpxp.htm

It is totally free and uses Ghostscript and the Apple Postscript driver.
Be sure to download the "Administration Manual" as well as the sources (some basic code samples) and perhaps even the multidocument option.

/gustav
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 27

Assisted Solution

by:jjafferr
jjafferr earned 332 total points
ID: 12392682


Here is a neat trick from
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20381304.html

What is happening here is:
1- You print your Report to Ms Word, here is an example on how to do that:
http://www.experts-exchange.com/Databases/MS_Access/Q_21023384.html

2- then print to pdf from Word.


reference ms word object library and acrobat distiller under project/references:

Dim obj As New Word.Application
Dim objDistiller As New ACRODISTXLib.PdfDistiller

obj.Documents.Open "C:\my documents\Test.doc"
obj.ActivePrinter = "Acrobat Distiller"
obj.PrintOut False, False, False, "C:\windows\desktop\Test.ps", , , , , , , True
obj.Quit False
Set obj = Nothing

objDistiller.FileToPDF "C:\windows\desktop\Test.ps", "c:\windows\desktop\Test.pdf", ""
Set objDistiller = Nothing



jaffer
0
 
LVL 44

Assisted Solution

by:Karl Heinz Kremer
Karl Heinz Kremer earned 332 total points
ID: 12392744
0
 
LVL 27

Expert Comment

by:jjafferr
ID: 12392869
khkremer, thanks for accepting my request to help here, much appreciated.

I have 2 suggestion:
1- Although EVERYBODy hates SendKeys, but it might get the job done here,
So when the Save dialog comes up, we Sendkey with the file Name and path, then sendkey for Carriage Return:

strAttach = "\\Torrdata\Manufacturing\RMR_Data\RMRs\RMR" & Me.RMRNum & ".pdf"
DoCmd.OpenReport "rptRMR", acnormal
SendKeys strAttach, False
SendKeys "{Enter}", False

2- Some good discussion and solutions too:
http://www.tek-tips.com/faqs.cfm?fid=1635
http://www.tek-tips.com/viewthread.cfm?qid=816439

jaffer
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question