I am trying to write some code to print an Access report to an adobe acrobat file. How do you specify the printer in Access VBA?
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Print report to Acrobat PDF (AccessXP)
Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Print report to Acrobat PDF (AccessXP)
- This topic has 118 replies, 13 voices, and was last updated 17 years, 1 month ago.
AuthorTopicWSMarie-Therese
AskWoody LoungerDecember 15, 2003 at 1:47 am #397977Viewing 9 reply threadsAuthorReplies-
WSjohnhutchison
AskWoody LoungerDecember 15, 2003 at 2:27 am #757415A simple alternative to writing VBA code to select a printer is to format the report for a specific printer.
Open the report in Design view and go to page setup.If you sometimes want to print and sometimes want to convert to pdf, you can have two copies of the report, with one set for the default printer and one for acrobat.
-
WSjohnhutchison
AskWoody LoungerDecember 15, 2003 at 2:27 am #757416A simple alternative to writing VBA code to select a printer is to format the report for a specific printer.
Open the report in Design view and go to page setup.If you sometimes want to print and sometimes want to convert to pdf, you can have two copies of the report, with one set for the default printer and one for acrobat.
-
WSHansV
AskWoody LoungerDecember 15, 2003 at 2:27 am #757417Look up the Printer object and property and the Printers collection in the online help, and look up the name of the “printer” for Acrobat (I don’t have that myself, so I don’t know the name)
Examples:
Me.Printer = Application.Printers(“Acrobat”)
where Me refers to the report, if the code is in the report module, or
Reports!MyReport.Printer = Application.Printers(“Acrobat”)
where MyReport is an open report.
-
WSMarie-Therese
AskWoody LoungerDecember 15, 2003 at 3:32 am #757425Thanks Hans. That worked. Now I have one more problem. After setting the printer, I cannot seem to save the report to the PDF file.
a) If I use Docmd.OutputTo, I can only save it in one of the Microsoft formats (eg RTF, etc..) , which corrupts the PDF file.
If I use Docmd.Printout, this doesn’t let me specify the destination.
What is the best way to print to an acrobat file, in a specific location?
-
WSHansV
AskWoody LoungerDecember 15, 2003 at 7:52 am #757474I believe it involves setting the filename in a Registry entry before printing the report (using PrintOut, not OutputTo). You can copy the code below into a standard module, then use
SetPDFFileName “C:AccessTest.pdf”
You might also use the PDF and Mail library for Access from ACG Soft. It’s not free, though.
Option Compare Database
Option ExplicitPrivate Declare Function RegOpenKeyA Lib “advapi32.dll” _
(ByVal HKEY As Long, ByVal sSubKey As String, ByRef hkeyResult As Long) As Long
Private Declare Function RegCloseKey Lib “advapi32.dll” _
(ByVal HKEY As Long) As Long
Private Declare Function RegSetValueExA Lib “advapi32.dll” _
(ByVal HKEY As Long, ByVal sValueName As String, _
ByVal dwReserved As Long, ByVal dwType As Long, _
ByVal sValue As String, ByVal dwSize As Long) As Long
Private Declare Function RegCreateKeyA Lib “advapi32.dll” _
(ByVal HKEY As Long, ByVal sSubKey As String, ByRef hkeyResult As Long) As LongPublic Enum HKEY_Enum
HKEY_CLASSES_ROOT = &H80000000
HKEY_CURRENT_USER = &H80000001
HKEY_LOCAL_MACHINE = &H80000002
HKEY_USERS = &H80000003
HKEY_CURRENT_CONFIG = &H80000004
HKEY_DYN_DATA = &H80000005
End EnumPublic Function SetRegValue(ByVal HKEY As HKEY_Enum, ByVal Path As String, _
ByVal Entry As String, ByVal Value As String) As Boolean‘ Set text value in registry
Dim lngKey As Long
On Error GoTo Proc_ErrorIf RegOpenKeyA(HKEY, Path, lngKey) 0 Then
RegCreateKeyA HKEY, Path, lngKey
End If
SetRegValue = (RegSetValueExA(lngKey, Entry, 0&, 1&, Value, Len(Value) + 1) = 0)
RegCloseKey lngKey
Exit FunctionProc_Error:
MsgBox Err.Description, vbCritical
End FunctionPublic Sub SetPDFFileName(sPath As String)
SetRegValue HKEY_CURRENT_USER, “SoftwareAdobeAcrobat PDFWriter”, _
“PDFFileName”, sPath
End Sub -
WSHansV
AskWoody LoungerDecember 15, 2003 at 7:52 am #757475I believe it involves setting the filename in a Registry entry before printing the report (using PrintOut, not OutputTo). You can copy the code below into a standard module, then use
SetPDFFileName “C:AccessTest.pdf”
You might also use the PDF and Mail library for Access from ACG Soft. It’s not free, though.
Option Compare Database
Option ExplicitPrivate Declare Function RegOpenKeyA Lib “advapi32.dll” _
(ByVal HKEY As Long, ByVal sSubKey As String, ByRef hkeyResult As Long) As Long
Private Declare Function RegCloseKey Lib “advapi32.dll” _
(ByVal HKEY As Long) As Long
Private Declare Function RegSetValueExA Lib “advapi32.dll” _
(ByVal HKEY As Long, ByVal sValueName As String, _
ByVal dwReserved As Long, ByVal dwType As Long, _
ByVal sValue As String, ByVal dwSize As Long) As Long
Private Declare Function RegCreateKeyA Lib “advapi32.dll” _
(ByVal HKEY As Long, ByVal sSubKey As String, ByRef hkeyResult As Long) As LongPublic Enum HKEY_Enum
HKEY_CLASSES_ROOT = &H80000000
HKEY_CURRENT_USER = &H80000001
HKEY_LOCAL_MACHINE = &H80000002
HKEY_USERS = &H80000003
HKEY_CURRENT_CONFIG = &H80000004
HKEY_DYN_DATA = &H80000005
End EnumPublic Function SetRegValue(ByVal HKEY As HKEY_Enum, ByVal Path As String, _
ByVal Entry As String, ByVal Value As String) As Boolean‘ Set text value in registry
Dim lngKey As Long
On Error GoTo Proc_ErrorIf RegOpenKeyA(HKEY, Path, lngKey) 0 Then
RegCreateKeyA HKEY, Path, lngKey
End If
SetRegValue = (RegSetValueExA(lngKey, Entry, 0&, 1&, Value, Len(Value) + 1) = 0)
RegCloseKey lngKey
Exit FunctionProc_Error:
MsgBox Err.Description, vbCritical
End FunctionPublic Sub SetPDFFileName(sPath As String)
SetRegValue HKEY_CURRENT_USER, “SoftwareAdobeAcrobat PDFWriter”, _
“PDFFileName”, sPath
End Sub
-
-
WSMarie-Therese
AskWoody LoungerDecember 15, 2003 at 3:32 am #757426Thanks Hans. That worked. Now I have one more problem. After setting the printer, I cannot seem to save the report to the PDF file.
a) If I use Docmd.OutputTo, I can only save it in one of the Microsoft formats (eg RTF, etc..) , which corrupts the PDF file.
If I use Docmd.Printout, this doesn’t let me specify the destination.
What is the best way to print to an acrobat file, in a specific location?
-
lmandel
AskWoody LoungerApril 12, 2004 at 12:52 pm #813442 -
WSHansV
AskWoody Lounger -
lmandel
AskWoody Lounger -
WSHansV
AskWoody LoungerApril 12, 2004 at 3:09 pm #813601As far as I know, setting the printer in Access 2000 is very ugly – see Controlling Your Printer. This chapter from the Access Developer’s Handbook is for Access 95, but it applies to Access 97 and 2000 as well.
Perhaps someone else has a simpler solution
-
WSHansV
AskWoody LoungerApril 12, 2004 at 3:09 pm #813602As far as I know, setting the printer in Access 2000 is very ugly – see Controlling Your Printer. This chapter from the Access Developer’s Handbook is for Access 95, but it applies to Access 97 and 2000 as well.
Perhaps someone else has a simpler solution
-
-
lmandel
AskWoody Lounger
-
-
WSHansV
AskWoody Lounger
-
-
lmandel
AskWoody LoungerApril 12, 2004 at 12:52 pm #813443 -
WSjj123
AskWoody Lounger -
WSFrancois
AskWoody Lounger -
WSFrancois
AskWoody Lounger
-
-
WSjj123
AskWoody Lounger
-
-
WSHansV
AskWoody LoungerDecember 15, 2003 at 2:27 am #757418Look up the Printer object and property and the Printers collection in the online help, and look up the name of the “printer” for Acrobat (I don’t have that myself, so I don’t know the name)
Examples:
Me.Printer = Application.Printers(“Acrobat”)
where Me refers to the report, if the code is in the report module, or
Reports!MyReport.Printer = Application.Printers(“Acrobat”)
where MyReport is an open report.
-
WSMarkLiquorman
AskWoody Lounger -
WSMarkLiquorman
AskWoody Lounger -
WSjj123
AskWoody Lounger -
WSFrancois
AskWoody Lounger -
WSjj123
AskWoody Lounger -
WSFrancois
AskWoody Lounger -
WSjj123
AskWoody Lounger -
WSFrancois
AskWoody LoungerSeptember 1, 2004 at 3:18 pm #871442The attached code is the same as in the previous post.
I have been playing the last hours with programming in the registry.
So far I can change the printer to print to the pdf distiller printer but until now I can’t find how to avoid the dialog to ask the file name.
If I find something, I’ll post back -
WSjj123
AskWoody Lounger -
WSFrancois
AskWoody LoungerSeptember 2, 2004 at 6:49 am #871767For the moment, if using windows xp, I can set the printer to print to pdf in code.
In Acrobat distiller you have an option to avoid to ask where to save. If you use this, the report is saved as a pdf file with the name of the report. sample: ReportName.pdf.
But this is saved on the desktop and I’m looking for a method to save it in a directory of your choice. That’s the last problem. -
WSjj123
AskWoody Lounger -
WSFrancois
AskWoody Lounger -
WSjj123
AskWoody Lounger -
WSjj123
AskWoody Lounger -
WSFrancois
AskWoody Lounger -
WSFrancois
AskWoody LoungerSeptember 2, 2004 at 7:35 am #871781This program is tested on a win xp and I don’t know if it will run on other windows version.
In the attachment you’ll find to txt files.
Extract them and copy the content of each of the files in a different new module. Save the modules but don’t use the name RunReportAsPDF as this is the name of the sub and a sub may not have the same name as a module.
For each report you want to run, use an instruction as follow :
Call RunReportAsPDF(“ReportName”,”PrinterName”)
Replace ReportName with the name of your report.
Replace Printer Name with the printer name you find in the registry when the Adobe Distiller is set as default.
To find this out :
Set the adobe distiller as default printer.
Go to Start , Run and type regedit.
Navigate to the key HKEY_CURRENT_USERSoftwareMicrosoftWIndows NTCurrentVersionWindows
Look in the right pane form the key Device and note the string. (On my pc it’s : Acrobat Distiller,winspool,Ne01: )
This is the text you have to use as PrinterName.
Close the regedit.
Set you usual printer as default back.Let me know how it turns out.
-
WSjj123
AskWoody Lounger -
WSFrancois
AskWoody LoungerSeptember 2, 2004 at 7:58 am #871791Yes, use a command button and in the click event use code like this :
Private Sub cmdPrintPDF_Click()
Call RunReportAsPDF(“Report1”, “Acrobat Distiller,winspool,Ne01:”)
Call RunReportAsPDF(“Report2”, “Acrobat Distiller,winspool,Ne01:”)
Call RunReportAsPDF(“Report3”, “Acrobat Distiller,winspool,Ne01:”)
Call RunReportAsPDF(“Report4”, “Acrobat Distiller,winspool,Ne01:”)
Call RunReportAsPDF(“Report5”, “Acrobat Distiller,winspool,Ne01:”)
End SubThe reports will be on the desktop. I can’t find the method to put them in a specific directory for the moment.
-
WSFrancois
AskWoody LoungerSeptember 2, 2004 at 7:58 am #871792Yes, use a command button and in the click event use code like this :
Private Sub cmdPrintPDF_Click()
Call RunReportAsPDF(“Report1”, “Acrobat Distiller,winspool,Ne01:”)
Call RunReportAsPDF(“Report2”, “Acrobat Distiller,winspool,Ne01:”)
Call RunReportAsPDF(“Report3”, “Acrobat Distiller,winspool,Ne01:”)
Call RunReportAsPDF(“Report4”, “Acrobat Distiller,winspool,Ne01:”)
Call RunReportAsPDF(“Report5”, “Acrobat Distiller,winspool,Ne01:”)
End SubThe reports will be on the desktop. I can’t find the method to put them in a specific directory for the moment.
-
WSjj123
AskWoody Lounger -
WSjj123
AskWoody Lounger -
WSFrancois
AskWoody Lounger -
WSjj123
AskWoody Lounger -
WSFrancois
AskWoody Lounger -
WSjj123
AskWoody Lounger -
WSFrancois
AskWoody Lounger -
WSjj123
AskWoody Lounger -
WSFrancois
AskWoody LoungerSeptember 2, 2004 at 10:19 am #871870The report CFT…. should exist in the database window on the tab reports.
The quotes should be on the same place as in the other lines.
Call RunReportAsPDF(“CFT…..”, “Acrobat Distiller,winspool,Ne01:”)
Around the report name and around the printer name.
Did the report name contain quotes ? if so rename it in the database window and in the code line with a name without quotes. -
WSjj123
AskWoody LoungerSeptember 2, 2004 at 10:29 am #871874The quotes are fine , see attachment.
I don’t understand what you are impying when you mean did the report name contain quotes?
I also don’t know what you mean when you say “The report CFT…. should exist in the database window on the tab reports”
Can you explain these in a bit more details,maybe include a screenshot so l can see what you mean.Justin.
-
WSFrancois
AskWoody LoungerSeptember 2, 2004 at 10:47 am #871884Look at the database window (see attachment)
Is the CFT Open Action Report in the list of reports ? Is the spelling exact the same as in the code ? Check for double spaces. See attachment one is with single space and the other with double space.
If this don’t work, select the report in the database window and press F2, then CTRL-C, go to the code window and put the cursor on the line for that report. Erase the report name and put the cursor between the two double quotes (“|”) end press CTRL-V -
WSjj123
AskWoody LoungerSeptember 2, 2004 at 11:27 am #871922The reports are there ok. They need to be different to the . PDF report name.
I don’t know what you mean by
“If this don’t work, select the report in the database window and press F2, then CTRL-C, go to the code window and put the cursor on the line for that report. Erase the report name and put the cursor between the two double quotes (“|”) end press CTRL-V”
I tried this but it did not work , see attachment.Justin
-
WSFrancois
AskWoody LoungerSeptember 2, 2004 at 11:40 am #871934That was to use a copy and past to copy the name of the report in the code.
In the lines calling the procedure where I told you to put the report name you should enter the exactly same name as appear in the database window, surrounded by double quotes.
From your attachment I see a report named Install CFT
If you want a pdf file from that report use the line :
Call RunReportAsPDF(“Install CFT”,”Acrobat Distiller,winspool,Ne00:”)
and when you run the code you’ll have on the desktop a file named : Install CFT.pfd -
WSjj123
AskWoody Lounger -
WSFrancois
AskWoody LoungerSeptember 2, 2004 at 11:59 am #871964I don’t understand.
You have created reports. You want them on paper or as pdf.
If you want them on paper, use the normal procedure : DoCmd OpenReport …
If you want them in a pdf file use my code.
if you need different reports on paper than in pdf, you’ll have to create new reports and use these new reports to create pdf files. -
WSjj123
AskWoody Lounger -
WSjj123
AskWoody Lounger -
WSFrancois
AskWoody LoungerSeptember 2, 2004 at 11:59 am #871965I don’t understand.
You have created reports. You want them on paper or as pdf.
If you want them on paper, use the normal procedure : DoCmd OpenReport …
If you want them in a pdf file use my code.
if you need different reports on paper than in pdf, you’ll have to create new reports and use these new reports to create pdf files. -
WSD Willett
AskWoody LoungerSeptember 2, 2004 at 12:02 pm #871966Justin
I think there’s a bit of confusion here.
why does the PDF need to be a different name to the Access report.
It would be much simpler to rename the reports within Access.You can right click on a report and select “Rename”
The reports must be named exactly as the code is trying to pull.If your users will be viewing the PDF’s as opposed to the Access Reports, this doesn’t really seem to be an issue.
-
WSjj123
AskWoody Lounger -
WSD Willett
AskWoody Lounger -
WSjj123
AskWoody Lounger -
WSD Willett
AskWoody Lounger -
WSD Willett
AskWoody Lounger -
WScharlotte
AskWoody LoungerSeptember 2, 2004 at 12:45 pm #872029You need to discuss the user requirements with your users because someone doesn’t understand the situation. Just because there is a user requirement doesn’t mean that it makes sense. Access and pdf reports *always* have a different name because Access reports don’t exist outside the Access database and pdf reports don’t exist inside it. The pdf report will have a pdf extension, while an Access report “printed” to Word will have an rtf extension. What more difference do you need?
-
WSjj123
AskWoody Lounger -
WSFrancois
AskWoody LoungerSeptember 2, 2004 at 2:10 pm #872089If you rename your reports to what the user want, you will have your pdf files with the right names.
If your application is well designed, the users would never see a report name. You should provide a menu or switch board, with whatever description you want, to launch the reports.
If you persist, the only (very bad) solution I see is duplicating the reports and use the ones for pdf files and the others for paper prints. -
WSjj123
AskWoody LoungerSeptember 2, 2004 at 2:25 pm #872098If l rename the report names then this would take the same amount of time as typing out the .pdf filesname in the first
place , therfore no need for the additional coding which you have provided.
I have designed a command button to run the reports.
If there is not a solution to not having to re-type out the pdf filenames , then l will see the user to see if he will allow me to call the .pdf filenames the same name as the report names.Thank you for your help today , it has been much appreciated.
Justin.
-
WScharlotte
AskWoody LoungerSeptember 2, 2004 at 5:34 pm #872209What are you talking about when you say “file names”? The pdf version of the report, once printed to the pdf printer, definitely has a file name. The Access report NEVER has a file name because it is not a FILE. The only way you get a file name for an Access report is to print it or output it to an rtf or excel format, for instance. Most PDF printers have a method of some sort that allows you to pass a filename to be created when generating the pdf file. You’ll need to look for that in the one you’re using if you want a different name from the default generated from the Access report’s name itself.
-
WScharlotte
AskWoody LoungerSeptember 2, 2004 at 5:34 pm #872210What are you talking about when you say “file names”? The pdf version of the report, once printed to the pdf printer, definitely has a file name. The Access report NEVER has a file name because it is not a FILE. The only way you get a file name for an Access report is to print it or output it to an rtf or excel format, for instance. Most PDF printers have a method of some sort that allows you to pass a filename to be created when generating the pdf file. You’ll need to look for that in the one you’re using if you want a different name from the default generated from the Access report’s name itself.
-
WSpatt
AskWoody Lounger -
WSjohnhutchison
AskWoody LoungerSeptember 2, 2004 at 10:56 pm #872427Here is how I do it using PDF995 in Access 2003.
* PDF995 has an option to specify a default filename for all files. Mine is set to catalogue.pdf. So I create the pdf, then make a copy of the file to the desired filename.
* As written my code uses another function I have not included fnGetLinkedPath that returns the location of the backend tables. You could replace that with a hardcoded value for mypath, which is where you want the file put.* I have also included the code needed for Sleep to work, because I call that.
* There is no error handling in this yet. I have only just cobbled this together from something slightly different.
Private Declare Sub sapiSleep Lib “kernel32” _
Alias “Sleep” _
(ByVal dwMilliseconds As Long)Sub sSleep(lngMilliSec As Long)
If lngMilliSec > 0 Then
Call sapiSleep(lngMilliSec)
End If
End SubSub sbPrintReporttoPDF(strReportName As String, strPDFfilename As String, strCriteria As String)
Dim blPDFinstalled As Boolean
Dim prt As Printer
Dim mypath As String
Dim prtDefault As Printer
mypath = fngetlinkedpath() & “”
blPDFinstalled = False
‘check if there is a printer called PDF995 – cant create pdfs without it
For Each prt In Printers
If prt.DeviceName = “PDF995” Then
blPDFinstalled = True
End If
Next prt
If blPDFinstalled = False Then
MsgBox “You have asked for a PDF to be created, but PDF995 is not installed.” & vbNewLine & “PDF995 is required for creation of PDF files”
Exit Sub
End IfIf Right(strPDFfilename, 3) “pdf” Then
Next prt strPDFfilename = strPDFfilename & “.pdf”
End IfSet prtDefault = Application.Printer
‘ to remember the current printer
Set Application.Printer = Application.Printers(“PDF995”)
DoCmd.OpenReport strReportName, acNormal, , strCriteria
Call sSleep(2000)
‘ otherwise the filecopy tries to happen before the previous step is finished.
FileCopy mypath & “catalogue.pdf”, mypath & strPDFfilenameSet Application.Printer = prtDefault
‘ to set the printer backEnd Sub
-
WSjohnhutchison
AskWoody LoungerSeptember 2, 2004 at 10:56 pm #872428Here is how I do it using PDF995 in Access 2003.
* PDF995 has an option to specify a default filename for all files. Mine is set to catalogue.pdf. So I create the pdf, then make a copy of the file to the desired filename.
* As written my code uses another function I have not included fnGetLinkedPath that returns the location of the backend tables. You could replace that with a hardcoded value for mypath, which is where you want the file put.* I have also included the code needed for Sleep to work, because I call that.
* There is no error handling in this yet. I have only just cobbled this together from something slightly different.
Private Declare Sub sapiSleep Lib “kernel32” _
Alias “Sleep” _
(ByVal dwMilliseconds As Long)Sub sSleep(lngMilliSec As Long)
If lngMilliSec > 0 Then
Call sapiSleep(lngMilliSec)
End If
End SubSub sbPrintReporttoPDF(strReportName As String, strPDFfilename As String, strCriteria As String)
Dim blPDFinstalled As Boolean
Dim prt As Printer
Dim mypath As String
Dim prtDefault As Printer
mypath = fngetlinkedpath() & “”
blPDFinstalled = False
‘check if there is a printer called PDF995 – cant create pdfs without it
For Each prt In Printers
If prt.DeviceName = “PDF995” Then
blPDFinstalled = True
End If
Next prt
If blPDFinstalled = False Then
MsgBox “You have asked for a PDF to be created, but PDF995 is not installed.” & vbNewLine & “PDF995 is required for creation of PDF files”
Exit Sub
End IfIf Right(strPDFfilename, 3) “pdf” Then
Next prt strPDFfilename = strPDFfilename & “.pdf”
End IfSet prtDefault = Application.Printer
‘ to remember the current printer
Set Application.Printer = Application.Printers(“PDF995”)
DoCmd.OpenReport strReportName, acNormal, , strCriteria
Call sSleep(2000)
‘ otherwise the filecopy tries to happen before the previous step is finished.
FileCopy mypath & “catalogue.pdf”, mypath & strPDFfilenameSet Application.Printer = prtDefault
‘ to set the printer backEnd Sub
-
WSpatt
AskWoody Lounger -
WSjj123
AskWoody LoungerSeptember 2, 2004 at 2:25 pm #872099If l rename the report names then this would take the same amount of time as typing out the .pdf filesname in the first
place , therfore no need for the additional coding which you have provided.
I have designed a command button to run the reports.
If there is not a solution to not having to re-type out the pdf filenames , then l will see the user to see if he will allow me to call the .pdf filenames the same name as the report names.Thank you for your help today , it has been much appreciated.
Justin.
-
WSFrancois
AskWoody LoungerSeptember 2, 2004 at 2:10 pm #872090If you rename your reports to what the user want, you will have your pdf files with the right names.
If your application is well designed, the users would never see a report name. You should provide a menu or switch board, with whatever description you want, to launch the reports.
If you persist, the only (very bad) solution I see is duplicating the reports and use the ones for pdf files and the others for paper prints. -
WSjj123
AskWoody Lounger -
WScharlotte
AskWoody LoungerSeptember 2, 2004 at 12:45 pm #872030You need to discuss the user requirements with your users because someone doesn’t understand the situation. Just because there is a user requirement doesn’t mean that it makes sense. Access and pdf reports *always* have a different name because Access reports don’t exist outside the Access database and pdf reports don’t exist inside it. The pdf report will have a pdf extension, while an Access report “printed” to Word will have an rtf extension. What more difference do you need?
-
WSjj123
AskWoody Lounger -
WSD Willett
AskWoody Lounger -
WSjj123
AskWoody Lounger -
WSD Willett
AskWoody LoungerSeptember 2, 2004 at 12:02 pm #871967Justin
I think there’s a bit of confusion here.
why does the PDF need to be a different name to the Access report.
It would be much simpler to rename the reports within Access.You can right click on a report and select “Rename”
The reports must be named exactly as the code is trying to pull.If your users will be viewing the PDF’s as opposed to the Access Reports, this doesn’t really seem to be an issue.
-
WScharlotte
AskWoody LoungerSeptember 2, 2004 at 12:09 pm #871976Users won’t be able to just “view” pdf reports the way they do an Access report. The PDF report is created by printing the Access report to a PDF printer. You will NEVER see the pdf report in the database window because it isn’t in Access, it’s a pdf file on the drive and it has to be opened with a pdf reader.
-
WScharlotte
AskWoody LoungerSeptember 2, 2004 at 12:09 pm #871977Users won’t be able to just “view” pdf reports the way they do an Access report. The PDF report is created by printing the Access report to a PDF printer. You will NEVER see the pdf report in the database window because it isn’t in Access, it’s a pdf file on the drive and it has to be opened with a pdf reader.
-
WSjj123
AskWoody Lounger -
WSFrancois
AskWoody LoungerSeptember 2, 2004 at 11:40 am #871935That was to use a copy and past to copy the name of the report in the code.
In the lines calling the procedure where I told you to put the report name you should enter the exactly same name as appear in the database window, surrounded by double quotes.
From your attachment I see a report named Install CFT
If you want a pdf file from that report use the line :
Call RunReportAsPDF(“Install CFT”,”Acrobat Distiller,winspool,Ne00:”)
and when you run the code you’ll have on the desktop a file named : Install CFT.pfd -
WSjj123
AskWoody LoungerSeptember 2, 2004 at 11:27 am #871923The reports are there ok. They need to be different to the . PDF report name.
I don’t know what you mean by
“If this don’t work, select the report in the database window and press F2, then CTRL-C, go to the code window and put the cursor on the line for that report. Erase the report name and put the cursor between the two double quotes (“|”) end press CTRL-V”
I tried this but it did not work , see attachment.Justin
-
WSjj123
AskWoody Lounger -
WSjj123
AskWoody Lounger -
WSFrancois
AskWoody LoungerSeptember 2, 2004 at 10:47 am #871885Look at the database window (see attachment)
Is the CFT Open Action Report in the list of reports ? Is the spelling exact the same as in the code ? Check for double spaces. See attachment one is with single space and the other with double space.
If this don’t work, select the report in the database window and press F2, then CTRL-C, go to the code window and put the cursor on the line for that report. Erase the report name and put the cursor between the two double quotes (“|”) end press CTRL-V -
WSD Willett
AskWoody LoungerSeptember 2, 2004 at 10:50 am #871894Justin
Francois has given all the information you require to complete your task.
What you must do is to create the reports first in your database.
The code relies on the reports first being present.
If the reports are not present, then the code has nothing to convert, unless as Francois suggests, they are not named correctly. -
WSjj123
AskWoody Lounger -
WSjj123
AskWoody Lounger -
WSD Willett
AskWoody LoungerSeptember 2, 2004 at 10:50 am #871895Justin
Francois has given all the information you require to complete your task.
What you must do is to create the reports first in your database.
The code relies on the reports first being present.
If the reports are not present, then the code has nothing to convert, unless as Francois suggests, they are not named correctly. -
WSjj123
AskWoody LoungerSeptember 2, 2004 at 10:29 am #871875The quotes are fine , see attachment.
I don’t understand what you are impying when you mean did the report name contain quotes?
I also don’t know what you mean when you say “The report CFT…. should exist in the database window on the tab reports”
Can you explain these in a bit more details,maybe include a screenshot so l can see what you mean.Justin.
-
WSFrancois
AskWoody LoungerSeptember 2, 2004 at 10:19 am #871871The report CFT…. should exist in the database window on the tab reports.
The quotes should be on the same place as in the other lines.
Call RunReportAsPDF(“CFT…..”, “Acrobat Distiller,winspool,Ne01:”)
Around the report name and around the printer name.
Did the report name contain quotes ? if so rename it in the database window and in the code line with a name without quotes. -
WSjj123
AskWoody Lounger -
WSFrancois
AskWoody Lounger -
WSjj123
AskWoody Lounger -
WSFrancois
AskWoody Lounger -
WSjj123
AskWoody Lounger -
WSFrancois
AskWoody Lounger -
WSjj123
AskWoody Lounger -
WSFrancois
AskWoody LoungerSeptember 2, 2004 at 7:35 am #871782This program is tested on a win xp and I don’t know if it will run on other windows version.
In the attachment you’ll find to txt files.
Extract them and copy the content of each of the files in a different new module. Save the modules but don’t use the name RunReportAsPDF as this is the name of the sub and a sub may not have the same name as a module.
For each report you want to run, use an instruction as follow :
Call RunReportAsPDF(“ReportName”,”PrinterName”)
Replace ReportName with the name of your report.
Replace Printer Name with the printer name you find in the registry when the Adobe Distiller is set as default.
To find this out :
Set the adobe distiller as default printer.
Go to Start , Run and type regedit.
Navigate to the key HKEY_CURRENT_USERSoftwareMicrosoftWIndows NTCurrentVersionWindows
Look in the right pane form the key Device and note the string. (On my pc it’s : Acrobat Distiller,winspool,Ne01: )
This is the text you have to use as PrinterName.
Close the regedit.
Set you usual printer as default back.Let me know how it turns out.
-
WSjj123
AskWoody Lounger -
WSFrancois
AskWoody LoungerSeptember 2, 2004 at 6:49 am #871768For the moment, if using windows xp, I can set the printer to print to pdf in code.
In Acrobat distiller you have an option to avoid to ask where to save. If you use this, the report is saved as a pdf file with the name of the report. sample: ReportName.pdf.
But this is saved on the desktop and I’m looking for a method to save it in a directory of your choice. That’s the last problem. -
WSjj123
AskWoody Lounger -
WSFrancois
AskWoody LoungerSeptember 1, 2004 at 3:18 pm #871443The attached code is the same as in the previous post.
I have been playing the last hours with programming in the registry.
So far I can change the printer to print to the pdf distiller printer but until now I can’t find how to avoid the dialog to ask the file name.
If I find something, I’ll post back -
WSjj123
AskWoody Lounger
-
-
WSFrancois
AskWoody Lounger
-
-
WSjj123
AskWoody Lounger
-
-
WSFrancois
AskWoody Lounger
-
-
WSjj123
AskWoody Lounger -
WSready4data
AskWoody Lounger -
WSkwvh
AskWoody Lounger -
WSlorraine
AskWoody Lounger
-
-
-
WSready4data
AskWoody Lounger
Viewing 9 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Login screen icon
by
CWBillow
35 minutes ago -
AI coming to everything
by
Susan Bradley
5 hours, 52 minutes ago -
Mozilla : Pocket shuts down July 8, 2025, Fakespot shuts down on July 1, 2025
by
Alex5723
8 hours, 3 minutes ago -
No Screen TurnOff???
by
CWBillow
8 hours, 25 minutes ago -
Identify a dynamic range to then be used in another formula
by
BigDaddy07
8 hours, 57 minutes ago -
InfoStealer Malware Data Breach Exposed 184 Million Logins and Passwords
by
Alex5723
20 hours, 34 minutes ago -
How well does your browser block trackers?
by
n0ads
6 hours, 52 minutes ago -
You can’t handle me
by
Susan Bradley
11 hours, 17 minutes ago -
Chrome Can Now Change Your Weak Passwords for You
by
Alex5723
6 hours, 20 minutes ago -
Microsoft: Over 394,000 Windows PCs infected by Lumma malware, affects Chrome..
by
Alex5723
1 day, 7 hours ago -
Signal vs Microsoft’s Recall ; By Default, Signal Doesn’t Recall
by
Alex5723
11 hours, 26 minutes ago -
Internet Archive : This is where all of The Internet is stored
by
Alex5723
1 day, 8 hours ago -
iPhone 7 Plus and the iPhone 8 on Vantage list
by
Alex5723
1 day, 8 hours ago -
Lumma malware takedown
by
EyesOnWindows
20 hours, 41 minutes ago -
“kill switches” found in Chinese made power inverters
by
Alex5723
1 day, 17 hours ago -
Windows 11 – InControl vs pausing Windows updates
by
Kathy Stevens
1 day, 17 hours ago -
Meet Gemini in Chrome
by
Alex5723
1 day, 21 hours ago -
DuckDuckGo’s Duck.ai added GPT-4o mini
by
Alex5723
1 day, 21 hours ago -
Trump signs Take It Down Act
by
Alex5723
2 days, 5 hours ago -
Do you have a maintenance window?
by
Susan Bradley
10 hours ago -
Freshly discovered bug in OpenPGP.js undermines whole point of encrypted comms
by
Nibbled To Death By Ducks
1 day, 7 hours ago -
Cox Communications and Charter Communications to merge
by
not so anon
2 days, 8 hours ago -
Help with WD usb driver on Windows 11
by
Tex265
46 minutes ago -
hibernate activation
by
e_belmont
2 days, 17 hours ago -
Red Hat Enterprise Linux 10 with AI assistant
by
Alex5723
2 days, 21 hours ago -
Windows 11 Insider Preview build 26200.5603 released to DEV
by
joep517
3 days ago -
Windows 11 Insider Preview build 26120.4151 (24H2) released to BETA
by
joep517
3 days ago -
Fixing Windows 24H2 failed KB5058411 install
by
Alex5723
1 day, 20 hours ago -
Out of band for Windows 10
by
Susan Bradley
3 days, 5 hours ago -
Giving UniGetUi a test run.
by
RetiredGeek
3 days, 12 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.