I cannot install any pdf writers on the machine. I need to print a MS access 2000 report to a pdf file so I can email this. I already have a PDF995 printer in my windows list of printers. All this needs to be done by VBA code.
5 8084 pks00 280
Recognized Expert Contributor
Sweet, your using pdf995, makes answering this question that much easier :)
okay, here is some vba code. Ive got a function called pdfwrite which you call passing in the name of the report, pdf destination and any criteria for running the report. Add this lot to a module
Look for comments saying "IMPORTANT
u need to change the paths to reflect your installation -
Declare Function GetPrivateProfileString Lib "kernel32" Alias _
-
"GetPrivateProfileStringA" (ByVal lpApplicationName As String, _
-
ByVal lpKeyName As Any, ByVal lpDefault As String, _
-
ByVal lpReturnedString As String, ByVal nSize As Long, _
-
ByVal lpFileName As String) As Long
-
-
Declare Function WritePrivateProfileString Lib "kernel32" Alias _
-
"WritePrivateProfileStringA" (ByVal lpApplicationName As String, _
-
ByVal lpKeyName As Any, ByVal lpString As Any, _
-
ByVal lpFileName As String) As Long
-
-
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
-
-
Sub pdfwrite(reportname As String, destpath As String, Optional strcriteria As String)
-
-
Dim syncfile As String, maxwaittime As Long
-
Dim iniFileName As String, tmpPrinter As Printer
-
Dim outputfile As String, X As Long
-
Dim tmpoutputfile As String, tmpAutoLaunch As String
-
-
'***** IMPORTANT - SEE THIS *****
-
' set the location of the PDF995.ini and the pdfsync files
-
iniFileName = "C:\Program Files\pdf995\res\pdf995.ini"
-
syncfile = "c:\documents and settings\all users\application data\pdf995\pdfsync.ini"
-
-
If Mid(destpath, Len(destpath), 1) <> "\" Then destpath = destpath & "\"
-
outputfile = destpath & reportname & ".pdf"
-
-
tmpoutputfile = ReadINIfile("PARAMETERS", "Output File", iniFileName)
-
tmpAutoLaunch = ReadINIfile("PARAMETERS", "Autolaunch", iniFileName)
-
-
On Error Resume Next
-
Kill outputfile
-
On Error GoTo Cleanup
-
-
X = WritePrivateProfileString("PARAMETERS", "Output File", outputfile, iniFileName)
-
X = WritePrivateProfileString("PARAMETERS", "AutoLaunch", "0", iniFileName)
-
-
Set tmpPrinter = Application.Printer
-
Application.Printer = Application.Printers("PDF995")
-
-
DoCmd.OpenReport reportname, acViewNormal, , strcriteria
-
-
Sleep (10000)
-
maxwaittime = 300000 'If pdf995 isn't done in 5 min, quit anyway
-
Do While ReadINIfile("PARAMETERS", "Generating PDF CS", syncfile) = "1" And maxwaittime > 0
-
Sleep (10000)
-
maxwaittime = maxwaittime - 10000
-
Loop
-
-
Cleanup:
-
Sleep (10000)
-
X = WritePrivateProfileString("PARAMETERS", "Output File", tmpoutputfile, iniFileName)
-
X = WritePrivateProfileString("PARAMETERS", "AutoLaunch", tmpAutoLaunch, iniFileName)
-
X = WritePrivateProfileString("PARAMETERS", "Launch", "", iniFileName)
-
On Error Resume Next
-
-
Application.Printer = tmpPrinter
-
-
End Sub
-
-
Function ReadINIfile(sSection As String, sEntry As String, sFileName As String) As String
-
-
Dim X As Long
-
Dim sDefault As String
-
Dim sRetBuf As String, iLenBuf As Integer
-
Dim sValue As String
-
-
sDefault$ = ""
-
sRetBuf$ = String$(256, 0) '256 null characters
-
iLenBuf% = Len(sRetBuf$)
-
X = GetPrivateProfileString(sSection, sEntry, _
-
sDefault$, sRetBuf$, iLenBuf%, sFileName)
-
ReadINIfile = Left$(sRetBuf$, X)
-
-
End Function
-
Hi,
Thanks for the speedy reply.
I tried the code but did not work. I did not get any errors though.
Firstly, I cannot find the file
syncfile = "c:\documen ts and settings\all users\applicati on data\pdf995\pdf sync.ini"
I searched for it in my entire C: drive. I do not have any other drives.
Secondly, I had to comment the following code as it is not supported by MS Access 2000;
'tmpPrinter As Printer
'Set tmpPrinter = Application.Pri nter
'Application.Pr inter = Application.Pri nters("PDF995")
'Application.Pr inter = tmpPrinter
Hi,
This code that you gave me was not working. I tried it again today, and for some reason, it works superbly without any errors. I am not sure why, maybe I needed to reboot my machine or something...Any ways, thanks...
pks00 280
Recognized Expert Contributor
Glad its working.
Ive tested this code and it works sweet for me. It now appears its working for you. Not sure why it didnt work in the first place, I can only imagine it wasnt working due to some configuration issue.
Sweet, your using pdf995, makes answering this question that much easier :)
okay, here is some vba code. Ive got a function called pdfwrite which you call passing in the name of the report, pdf destination and any criteria for running the report. Add this lot to a module
Look for comments saying "IMPORTANT
u need to change the paths to reflect your installation -
Declare Function GetPrivateProfileString Lib "kernel32" Alias _
-
"GetPrivateProfileStringA" (ByVal lpApplicationName As String, _
-
ByVal lpKeyName As Any, ByVal lpDefault As String, _
-
ByVal lpReturnedString As String, ByVal nSize As Long, _
-
ByVal lpFileName As String) As Long
-
-
Declare Function WritePrivateProfileString Lib "kernel32" Alias _
-
"WritePrivateProfileStringA" (ByVal lpApplicationName As String, _
-
ByVal lpKeyName As Any, ByVal lpString As Any, _
-
ByVal lpFileName As String) As Long
-
-
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
-
-
Sub pdfwrite(reportname As String, destpath As String, Optional strcriteria As String)
-
-
Dim syncfile As String, maxwaittime As Long
-
Dim iniFileName As String, tmpPrinter As Printer
-
Dim outputfile As String, X As Long
-
Dim tmpoutputfile As String, tmpAutoLaunch As String
-
-
'***** IMPORTANT - SEE THIS *****
-
' set the location of the PDF995.ini and the pdfsync files
-
iniFileName = "C:\Program Files\pdf995\res\pdf995.ini"
-
syncfile = "c:\documents and settings\all users\application data\pdf995\pdfsync.ini"
-
-
If Mid(destpath, Len(destpath), 1) <> "\" Then destpath = destpath & "\"
-
outputfile = destpath & reportname & ".pdf"
-
-
tmpoutputfile = ReadINIfile("PARAMETERS", "Output File", iniFileName)
-
tmpAutoLaunch = ReadINIfile("PARAMETERS", "Autolaunch", iniFileName)
-
-
On Error Resume Next
-
Kill outputfile
-
On Error GoTo Cleanup
-
-
X = WritePrivateProfileString("PARAMETERS", "Output File", outputfile, iniFileName)
-
X = WritePrivateProfileString("PARAMETERS", "AutoLaunch", "0", iniFileName)
-
-
Set tmpPrinter = Application.Printer
-
Application.Printer = Application.Printers("PDF995")
-
-
DoCmd.OpenReport reportname, acViewNormal, , strcriteria
-
-
Sleep (10000)
-
maxwaittime = 300000 'If pdf995 isn't done in 5 min, quit anyway
-
Do While ReadINIfile("PARAMETERS", "Generating PDF CS", syncfile) = "1" And maxwaittime > 0
-
Sleep (10000)
-
maxwaittime = maxwaittime - 10000
-
Loop
-
-
Cleanup:
-
Sleep (10000)
-
X = WritePrivateProfileString("PARAMETERS", "Output File", tmpoutputfile, iniFileName)
-
X = WritePrivateProfileString("PARAMETERS", "AutoLaunch", tmpAutoLaunch, iniFileName)
-
X = WritePrivateProfileString("PARAMETERS", "Launch", "", iniFileName)
-
On Error Resume Next
-
-
Application.Printer = tmpPrinter
-
-
End Sub
-
-
Function ReadINIfile(sSection As String, sEntry As String, sFileName As String) As String
-
-
Dim X As Long
-
Dim sDefault As String
-
Dim sRetBuf As String, iLenBuf As Integer
-
Dim sValue As String
-
-
sDefault$ = ""
-
sRetBuf$ = String$(256, 0) '256 null characters
-
iLenBuf% = Len(sRetBuf$)
-
X = GetPrivateProfileString(sSection, sEntry, _
-
sDefault$, sRetBuf$, iLenBuf%, sFileName)
-
ReadINIfile = Left$(sRetBuf$, X)
-
-
End Function
-
HI pks00
I was going through the codes as i have a similar problem. I want to generate the report in PDF format when a command button is clicked
But as i am new to the access programming. I could not understand it properly.
Could you please help me out as to How to generate a report in PDF format when a command button is clicked. I too Have "PDF995" as well as "Cute PDF writer"
Please help me out.
Thank you
Regards
Manoj
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: gudia |
last post by:
I want to Programatically generate Access reports in the pdf format
using some tool and then email them to people in the same code. Right
now I am trying to do this with pdf995 using VBA (emailing is a
separate issue, which pdf995 does not addresses).
I downloaded pdf995. It controls printing via pdf995.ini file. In the
VBA code, I have DoCmd.OpenReport "Report2", acViewNormal. I am having
the following problems right now.
(a) I do...
|
by: cyranoVR |
last post by:
This is the approach I used to automate printing of Microsoft Access
reports to PDF format i.e. unattended and without annoying "Save As..."
dialogs, and - more importantly - without having to use a commercial
program such as Adobe Acrobat and its associated API.
The technique uses Ghostscript and Redirection Port Monitor - two free
programs for creating PDF documents provided free by Russell Lang. The
actual automation requires VBA...
|
by: cantelow |
last post by:
Hi. I've got a program printing multiple pdf reports, and I need to
wait for completion of various associated operations- The pdf printer
prints to one file, then I need to copy that where I need it, then
delete the old file, repeat with the next report. I need to wait for
each step to complete or I get errors due to the previous thing being
open and not done yet.
Is there any elegant way to do that? My FileCopy in particular has...
|
by: Jason |
last post by:
For some reason, most but not all reports printing from an access
application our client is using will not print any images on the reports
or forms. One report will print the image and data correctly oddly enough.
The image header is embedded using the Insert Image feature and not
loaded into a database. I can move the image to anywhere in the report
and still it will not print out. I've loaded the most recent printer
drivers and...
|
by: Thomas Zimmermann |
last post by:
Is it possible from VBA to control which printer a report is send to? The
"DoCmd.OpenReport", always sends the job to the standardprinter, but I want
to be able to specify an alternative printer from code.
Any suggestions? Thanks in advance.
| |
by: salad |
last post by:
Hi Guys: I was stuck. I needed to send a report to a file. My
beautiful report(s) in Access were going to require loss of formatting
with RTFs, a PITA in WordMailMerge, sending it as a text file...whatever.
I described my situation to the guy I'm doing work for and he did some
research for me and came up with the following link.
http://www.novapdf.com/
The part that should excite us Access developers is their SDK
|
by: jbonifacejr |
last post by:
This is my first day here, so please be patient. I do not know how to
search very well so the search I tried to get the answer showed me
topics from the year 2000 and they really don't cover what I want.
I am trying to open MSAccess from ASP..I guess I would use
server.createobject("Access.Application")
OK, but where do i go from there to run a report and have it print to
the default printer?
|
by: Gilberto |
last post by:
pks00
Expert
280 Posts April 16th, 2007
01:08 PM
Re: How to print MS Access 2000 report to PDF995 printer by VBA Code
Sweet, your using pdf995, makes answering this question that much easier :)
|
by: Snoopy33 |
last post by:
I have a DB that I developed on access XP (2002) and deployed over a
year ago. No one has had problems printing any of the reports within
the DB until we started loading 2007 on new computers. The access
2007 users cannot print one of the reports. This is maddening since I
cannot duplicate the issue on any computer that runs 2003 or below.
Is there something going on that I'm not seeing? Does anyone have any
suggestions at all on...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |