Need to set registry keys programatically in Access

Hello Experts;

I am trying to do some automatic PDFing in access, and have this to go on;

However, that code doesn't work in my Access Database.

Can anyone show me the right code to do it within Access?
Who is Participating?
Scott McDaniel (Microsoft Access MVP - EE MVE )Connect With a Mentor Infotrakker SoftwareCommented:
Do you have the CutePDF Writer with Programattic Access? If not, those reg keys won't do you any good. I have this utility and it works very well, but it's pricey. The Lebans method mentioned by gustav might do fine for you.

Here's a post with a module that allows registry modifications; see the last posting for the code:
Gustav BrockCIOCommented:
First, you need to set a reference to Word in menu Tools, References.

Then, the registry functions must be declared in your code module.
Browse here to the comment from "James":

OzoneFriendlyAuthor Commented:
Sorry, I should have been more specific;

I don't want to use word; What I want to do is have the program automatically create a PDF copy of a report I have created in Access.

I have all the code necessary to find the right data and open the report, and I should be able to change that code to print instead of open the report;

I just need to be able to set a couple of registry keys so that the PDF software will automatically save the PDF where I want with the name I want.

I'll have a look at your link though and see what I can learn there.
Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

Gustav BrockCIOCommented:
If so, install a pdf printer like this (free, uses Apple Postscript and Ghostscipt and comes with a multi lingual UI):

and select that as your default printer or set the report to use that printer.

Another method is to use snapshot files and the code from Lebans:

Also, search the archive here for writing/printing to pdf. Numerous suggestions exist.

OzoneFriendlyAuthor Commented:
Hello experts;

Thanks for your suggestions; I have purchased the CutePDF solution, so now I just need to figure out the registry key setting code, and I should be all good. I'l look into LSMConsulting's suggestions now and see what I come up with.
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
If you have the CutePDF with Programatic Acces, then you can use the code shown in your earlier code. Note that you must also have a converter:

PDF writer requires PS2PDF converter such as GPL Ghostscript (recommended).

The utility used to ship with this converter, but it's a separate download now.
OzoneFriendlyAuthor Commented:
Thanks LSMConsulting!

The answer to my question was certainly not a one line paragraph as I had hoped, but your pointers got me on the right track.

With the help of these questions;

I found this link;

And used that stuff to make it work.  I incorporated the .bas file as a module in my access database, and could then use this code to set the registry keys;

regCreate_A_Key HKEY_CURRENT_USER, "Software\PDF Creator"
regCreate_Key_Value HKEY_CURRENT_USER, "Software\PDF Creator", "Outputfile", "c:\poles\inv.pdf"
regCreate_A_Key HKEY_CURRENT_USER, "Software\PDF Creator"
regCreate_Key_Value HKEY_CURRENT_USER, "Software\PDF Creator", "BypassSaveAs", "1"

I had to make one minor change to the .bas code I got, as it was setting up the registry value as a DWORD if the data was numeric; CutePDF wants on REG_SZ. So I just made it always create REG_SZ, which is fine for this application.

Sensational. :-)

Thanks for your help.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.