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 :)
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
-
Following this old thread i was just wondering WHERE exactly i should enter the code??? Sorry but im new on this.
Thanks,
Gilberto
1 2350 nico5038 3,080
Recognized Expert Specialist
Just create a new module and name it e.g. "modPrintPDF".
Copy/paste the code and give it a try.
Nic;o)
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: dexterb |
last post by:
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...
|
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. ...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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...
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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...
|
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...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |