Question

Change pdf filename programmatically using Adobe Acrobat 6.0 Professional

Asked by: alexisbr

Hi.  I have been playing with this for a while now.  I am testing this logic from Access 2003 in XP although we really need this to work in another application in XP that is not very well known (Vee 7.5.)

I am printing an Access report directly to a pdf file.  I unchecked the checkbox for "Prompt for Adobe PDF filename" and set the port to save to the folder I want.  That is all working.  However, the pdffile name is being set each time to the Access report caption (Deposition.pdf).  I need to be able to set the filename each time it is printed.

Here's the code I have that works along with the Adobe settings.
stDocName = "rptDeposition"
DoCmd.OpenReport stDocName, acViewPreview, , "SampleID='" & Me.SampleID & "'"
DoCmd.PrintOut

Is there an easy way to tell Adobe what filename I want to use?  I hope that figuring it out in Access will help me figure it out in the other application.  We have Adobe Acrobat 6.0 Professional and Acrobat Distiller 6.0.

Thanks for your help.
Alexis

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2008-10-29 at 10:39:16ID23858934
Topics

Adobe Acrobat

,

Microsoft Access Database

Participating Experts
1
Points
500
Comments
17

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Adobe Acrobat
    Does anyone know of a way to print Adobe Acrobat files within Delphi (either 1, 2 or 3) without calling Acrobat? I would prefer a component, but anything will help. Many thanks!
  2. PCL and Adobe Acrobat distiller
    Can a printer with PCL and Postscript emulation create pdf files using Adobe Acrobat distiller Thinking of buying a Lexmark or Samsung with both Thanks trexette
  3. adobe distiller
    Hi all, I need to print rtf documents to the Acrobat Distiller virtual printer automatically. And I need to be able to specify what the output PDF filename should be. Any one can provide example using adobe ocx ?
  4. Cannot distill with Adobe Acrobat
    Hi All, I'm having a recurring problem with distilling a file. I open the PRINT dialog box, choose ADOBE PDF. Then while it is distilling, The error message I get is -- The instruction at "0x00441ae2" referenced memory at "0x01dfeb6c". The memory could no...
  5. How to write script to use Adobe Acrobat Distiler or PDFwri…
    Is there a way to setup and script so that the destination and file name of the PDF is automatic and the user can not change it via Adobe Acrobat Distiller or PDFwriter?

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: khkremerPosted on 2008-10-29 at 11:39:15ID: 22834226

Starting with Acrobat 7, yes there is an easy way to configure the output filename (by setting a registry key), but this was not available in Acrobat 6. Can you upgrade Acrobat?

If not, you have some work to do: You first need to create a PostScript file, then you run Distiller (using the Distiller API that is documented by Adobe) to convert that PostScript file to a PDF file.

 

by: alexisbrPosted on 2008-10-29 at 14:48:04ID: 22836075

Thanks, khkremer.  I don't know if upgrading is an option.  We may have found a workaround in the meantime.  Let me try this workaround and I will get back to you.
Thanks,
Alexis

 

by: alexisbrPosted on 2008-10-31 at 10:23:35ID: 22852265

khkremer.
We can upgrade to Acrobat 9 Professional.  If so, how do we change the filename using the registry key?  Also, we will have multiple pages to print to one pdf file before we want to change the name.  Can we set Acrobat to not create a new pdf each time we do a printscreen and have the ability to tell Adobe when we are done printing to that pdf and to start a new one?  I can open a new question for that if you want.

We almost had this process working using pdfFactory but we are running into some inconsistencies and may end up having to use Adobe after all.

Also, I won't be back to this client again until Wed so I can't test anything out until then.
Thanks,
Alexis

 

by: khkremerPosted on 2008-10-31 at 10:30:36ID: 22852333

Take a look at the Distiller API Reference (http://www.adobe.com/devnet/acrobat/pdfs/Distiller9APIReference.pdf) - this document shows you how to turn off the prompt for the filename and provide the name via the registry key.

Unfortunately, you can only do this for one job at a time (unless you can send all the pages in the same print operation). So you would need to collect a number of PDF documents, and then when you are done you can use VBA to automate Acrobat to combine all these documents into the one output document.

 

by: khkremerPosted on 2008-10-31 at 10:31:38ID: 22852345

One more thing: The registry key is dependent on the application name, so your program needs to be changed when you move the solution from Access to Vee.

 

by: alexisbrPosted on 2008-10-31 at 11:44:55ID: 22853049

We are currently testing in Vee only.  I am no longer testing in Access.  We worked around the filename problem by writing a VBScript program to rename the Vee.pdf file created by the process after the process is done.  The Vee application can call a batch file so I created a batch file that calls my VBS program.  That works, however, we ran into some timing issues with the VBS trying to change the name even though the pdf has not finished being written yet.    

We're not sure if we can write VB code from within Vee.  That's why we tried to figure out a solution that would be outside of Vee.  If I can change the registry key and combine multiple PDF documents using VBScript, that should work from Vee.

Thanks,
Alexis

 

by: khkremerPosted on 2008-11-03 at 04:33:50ID: 22866471

Your timing issues would be resolved by setting this registry key. Can you run a batch script before the print operation?

 

by: alexisbrPosted on 2008-11-03 at 04:40:17ID: 22866502

Yes, we can run a batch script at any point, including before we print.  We are printing using the equivalent of a printscreen and have the pdf driver set as the default printer.  This PC will not be used for anything but our application so this is not a problem.

Thanks,
Alexis

 

by: khkremerPosted on 2008-11-03 at 04:44:50ID: 22866533

OK, in that case it's simple: Just set the registry key in your pre-print batch script (that of course requires that you have access to your desired output name at that time). It does not matter at which time you set the key, as long as it is set when you actually submit the job to the Adobe PDF printer. Distiller will remove the key after it's done, so you have to set it again the next time around (to a different name to avoid overwriting the first one).

 

by: alexisbrPosted on 2008-11-03 at 04:54:45ID: 22866587

We know the desired filename at the very begining of the process.   I can set the registry key.  However, since we call the print several times before we are done but we want one pdf file, I will have to combine the multiple pdf files.  I will probably have to keep resetting the registry key before each print to filename_1, filename_2, etc. (where filename is our desired filename) so I can combine them at the end.  I will be at the client on Wed and will try to test this out. I have to review the API to figure out the registry key and combine files syntax.

Thanks for your help.  I'll let you know how it goes.
Alexis

 

by: khkremerPosted on 2008-11-03 at 05:12:24ID: 22866719

Your first attempt may not work - because you may not know the correct application name. Do you have access to the application before you visit your client? If so, you should run a few tests to find out what the application uses as it's name when it initiates the print request.

Once way to do that is to check a different registry key. I describe the method in this question:
http://www.experts-exchange.com/Web_Development/Document_Imaging/Adobe_Acrobat/Q_23629368.html

(here is the one comment that you actually need from that discussion:
OK, then you may have the correct program filename. Use your application and print to the Adobe PDF printer, then open regedit and look in the PrinterJobControl key. There should be a new value with a name that starts with "LastPdfPortFolder - ", followed by the application name (unfortunately, it does not list the path). Is that the same application name that you've used?)

 

by: alexisbrPosted on 2008-11-03 at 05:20:07ID: 22866767

I think I understand what you are saying.  Unfortunately, the applicaiton is an engineering app that I do not have access to unless I am there.  I will do what you said and get the name from regedit.  I know the app outputs all pdf files to the name vee.pdf but that may be different from what I will see in regedit.

Thanks again for all the details.  I've never had to work with pdf file creation before.  The project we are working on is very important to the company and this printing issue is the last hurdle and it is complete.

Regards,
Alexis

 

by: alexisbrPosted on 2008-11-05 at 13:58:45ID: 22890452

I set the registry key, however, when I tested using Wordpad as you suggested in some other posts, it doesn't work.  The pdf file name is not going to where I wanted and doesn't have the filename I set.  Plus, the registry key is still there after I print so I know something's wrong.

I attached a screenshot of the registry setting I created.  Did I do something wrong?  I installed Adobe Acrobat Professional 9.0 before I did any of this.  Once I get the Wordpad example working, I will try to get it to work with the Vee application.

Thanks,
Alexis

 

by: alexisbrPosted on 2008-11-05 at 14:13:15ID: 22890602

I figured out the problem after doing  more testing.  Although my registry setting was correct, I had changed the Adobe Output PDF Folder setting from "prompt" to a physical folder.  I thought maybe that was interfering with the registry.  When I put the setting back to "prompt", and then ran Wordpad, it worked.  Now I will try to write a batch script to change the setting so I can call it from the vee program.  I'll let you know if I have any questions.
Thanks,
Alexis

 

by: alexisbrPosted on 2008-11-05 at 16:22:15ID: 22891425

Hi khkremer,
I tested manually setting the registry key for the vee application and the pdf file was created correctly.  I reviewed various posts on windows scripting but I can't get a complete file written.  I'd like to do this in VBScript.  For now, I want to get it to work with the Wordpad example.  I wrote a script below based on code I found but I don't know where to tell the script that the application is Wordpad.  The two string values I manually entered in regedit under "HKEY_CURRENT_USER\SOFTWARE\ADOBE\Acrobat Distiller\PrinterJobControl" are "C:\Program Files\Windows NT\Accessories\wordpad.exe" and "C:\Documents and Settings\processtest\My Documents\MyPDFFiles\mypdf.pdf".  How do I get both values in the script?  Am I even close here (see code snippet)?
Thanks,
Alexis


Dim WshShell, bKey
Set WshShell = WScript.CreateObject("WScript.Shell")
myKey = "HKEY_CURRENT_USER\SOFTWARE\ADOBE\Acrobat Distiller\PrinterJobControl\" 
WshShell.RegWrite myKey, "C:\Documents and Settings\processtest\My Documents\MyPDFFiles\mypdf.pdf", "REG_SZ"
set WshShell = Nothing
                                              
1:
2:
3:
4:
5:

Select allOpen in new window

 

by: khkremerPosted on 2008-11-06 at 05:10:06ID: 22894509

I am not familiar enough with VB to comment on your script - I'll try it anyways :)

If you look at the sample in the Adobe documentation, you'll see that the application name is actually part of the key (this is Adobe's Wordpad example):

Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Adobe\Acrobat Distiller\PrinterJobControl]
"C:\Program Files\Windows NT\Accessories\wordpad.exe" =
"c:\MyPDFoutputFileName.pdf"

The subkey in PrinterJobControl has the value of the PDF output path. As I said, I'm not an expert in VBS, but I searched a bit and found the following:

http://msdn.microsoft.com/en-us/library/aa393600.aspx

And I got the following code to work:

const HKEY_CURRENT_USER = &H80000001
strComputer = "."
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\"&_ 
    strComputer & "\root\default:StdRegProv")
 
strKeyPath = "SOFTWARE\Adobe\Acrobat Distiller\PrinterJobControl"
KeyPath = "SOFTWARE\Adobe\Acrobat Distiller\PrinterJobControl"
strValueName = "C:\Program Files\Windows NT\Accessories\wordpad.exe"
strValue = "c:\output.pdf"
 
 
 
    ' write string value to key    
    Return = objReg.SetStringValue( _
        HKEY_CURRENT_USER,strKeyPath,strValueName,strValue)
    If (Return = 0) And (Err.Number = 0) Then 
        Wscript.Echo "Success"
    Else
        Wscript.Echo "SetStringValue failed. Error = " & Err.Number
    End If

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:

Select allOpen in new window

 

by: alexisbrPosted on 2008-11-06 at 08:34:56ID: 22896865

Thanks, khkremer.  That worked.  I really appreciate it.  I worked on this quite a bit yesterday afternoon but just couldn't find the proper syntax.

If I have any more questions on getting this to work, I will open a new question.

Thanks again.
Alexis

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...