Solved

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

Posted on 2004-10-18
8
1,322 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 51

Accepted Solution

by:
Gustav Brock earned 84 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 27

Assisted Solution

by:jjafferr
jjafferr earned 83 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 83 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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

623 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