473,387 Members | 1,463 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Access 2003: Converting .snp files to .pdf files

1
I'm using an app designed in Access 2003 which exports a report into a .snp file. We are manually converting the snp files into pdf. I'll looking for away to convert the files from snp to pdf automatically via Access. I believe the Adobe Distiller linked to Access would automate this for us but I do not know how to link Access to the Distiller so a pdf is created. Does anyone know how to do this?

Thanks
Lisa
Apr 9 '07 #1
2 18108
MMcCarthy
14,534 Expert Mod 8TB
Hi Lisa

Try this website. I haven't tried it but Stephen Lebans code is usually very good.

http://www.lebans.com/reporttopdf.htm
Apr 10 '07 #2
pks00
280 Expert 100+
Hi Lisa

What I have used successfully in the past is PDF995. I have vba code that allows you to print your report as PDF using PDF995

Add the following to a module, note u would need to tweak this to reflect the path where you have installed it - read the comments within the procedure called pdfwrite
i.e.
'***** IMPORTANT - SEE THIS *****
' set the location of the PDF995.ini and the pdfsync files
iniFileName = "C:\Program Files\pdf995\res\pdf995.ini"


Expand|Select|Wrap|Line Numbers
  1.  
  2. 'Read INI settings
  3. Declare Function GetPrivateProfileString Lib "kernel32" Alias _
  4.    "GetPrivateProfileStringA" (ByVal lpApplicationName As String, _
  5.    ByVal lpKeyName As Any, ByVal lpDefault As String, _
  6.    ByVal lpReturnedString As String, ByVal nSize As Long, _
  7.    ByVal lpFileName As String) As Long
  8.  
  9. 'Write settings
  10. Declare Function WritePrivateProfileString Lib "kernel32" Alias _
  11.    "WritePrivateProfileStringA" (ByVal lpApplicationName As String, _
  12.    ByVal lpKeyName As Any, ByVal lpString As Any, _
  13.    ByVal lpFileName As String) As Long
  14.  
  15. Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
  16.  
  17. Sub pdfwrite(reportname As String, destpath As String, Optional strcriteria As String)
  18.  
  19.     ' Runs an Access report to PDF995 to create a pdf file from the report.
  20.     ' Input parameters are the name of the report within the current database,
  21.     ' the path for the output file, and an optional criteria for the report
  22.  
  23.     ' Be sure to check that the "Generating PDF CS" setting in pdfsync.ini is set to 0
  24.     ' when pdf995 is idle. This codes uses that as a completion flag as it seems to be
  25.     ' the most reliable indication that PDF995 is done writing the pdf file.
  26.  
  27.  
  28.     ' Note: The application.printer object is not valid in Access 2000
  29.     ' and earlier. In that case, set the printer in the report to pdf995
  30.     ' and comment out the references herein to the application.printer
  31.  
  32.     Dim syncfile As String, maxwaittime As Long
  33.     Dim iniFileName As String, tmpPrinter As Printer
  34.     Dim outputfile As String, X As Long
  35.     Dim tmpoutputfile As String, tmpAutoLaunch As String
  36.  
  37. '***** IMPORTANT - SEE THIS *****
  38.     ' set the location of the PDF995.ini and the pdfsync files
  39.     iniFileName = "C:\Program Files\pdf995\res\pdf995.ini"
  40.     syncfile = "c:\documents and settings\all users\application data\pdf995\pdfsync.ini"
  41.  
  42.     ' build the output file name from the path parameter and the report name
  43.     If Mid(destpath, Len(destpath), 1) <> "\" Then destpath = destpath & "\"
  44.     outputfile = destpath & reportname & ".pdf"
  45.  
  46.     ' PDF995 operates asynchronously. We need to determine when it is done so we can
  47.     ' continue. This is done by creating a file and having PDF995 delete it using the
  48.     ' ProcessPDF parameter in its ini file which runs a command when it is complete.
  49.  
  50.     ' save current settings from the PDF995.ini file
  51.     tmpoutputfile = ReadINIfile("PARAMETERS", "Output File", iniFileName)
  52.     tmpAutoLaunch = ReadINIfile("PARAMETERS", "Autolaunch", iniFileName)
  53.  
  54.     ' remove previous pdf if it exists
  55.     On Error Resume Next
  56.     Kill outputfile
  57.     On Error GoTo Cleanup
  58.  
  59.     ' setup new values in PDF995.ini
  60.     X = WritePrivateProfileString("PARAMETERS", "Output File", outputfile, iniFileName)
  61.     X = WritePrivateProfileString("PARAMETERS", "AutoLaunch", "0", iniFileName)
  62.  
  63.     ' change the default printer to PDF995
  64.     ' if running on Access 2000 or earlier, comment out the next two lines
  65.     Set tmpPrinter = Application.Printer
  66.     Application.Printer = Application.Printers("PDF995")
  67.  
  68.     'print the report
  69.     DoCmd.OpenReport reportname, acViewNormal, , strcriteria
  70.  
  71.     ' cleanup delay to allow PDF995 to finish up. When flagfile is nolonger present, PDF995 is done.
  72.     Sleep (10000)
  73.     maxwaittime = 300000 'If pdf995 isn't done in 5 min, quit anyway
  74.     Do While ReadINIfile("PARAMETERS", "Generating PDF CS", syncfile) = "1" And maxwaittime > 0
  75.         Sleep (10000)
  76.         maxwaittime = maxwaittime - 10000
  77.     Loop
  78.  
  79.     ' restore the original default printer and the PDF995.ini settings
  80. Cleanup:
  81.     Sleep (10000)
  82.     X = WritePrivateProfileString("PARAMETERS", "Output File", tmpoutputfile, iniFileName)
  83.     X = WritePrivateProfileString("PARAMETERS", "AutoLaunch", tmpAutoLaunch, iniFileName)
  84.     X = WritePrivateProfileString("PARAMETERS", "Launch", "", iniFileName)
  85.     On Error Resume Next
  86.  
  87.     ' if running on Access 2000 or earlier, comment out the next line
  88.     Application.Printer = tmpPrinter
  89.  
  90. End Sub
  91.  
  92. Function ReadINIfile(sSection As String, sEntry As String, sFileName As String) As String
  93.  
  94.     Dim X As Long
  95.     Dim sDefault As String
  96.     Dim sRetBuf As String, iLenBuf As Integer
  97.     Dim sValue As String
  98.  
  99.     'Six arguments
  100.     'Explanation of arguments:
  101.     'sSection: ini file section (always between brackets)
  102.     'sEntry : word on left side of "=" sign
  103.     'sDefault$: value returned if function is unsuccessful
  104.     'sRetBuf$ : the value you're looking for will be copied to this buffer string
  105.     'iLenBuf% : Length in characters of the buffer string
  106.     'sFileName: Path to the ini file
  107.  
  108.     sDefault$ = ""
  109.     sRetBuf$ = String$(256, 0)   '256 null characters
  110.     iLenBuf% = Len(sRetBuf$)
  111.     X = GetPrivateProfileString(sSection, sEntry, _
  112.                sDefault$, sRetBuf$, iLenBuf%, sFileName)
  113.     ReadINIfile = Left$(sRetBuf$, X)
  114.  
  115. End Function
  116.  
  117.  
  118.  

Now to call it, just call pdfwrite
eg pass in report name and folder where u want it dumped to

pdfwrite "Report1", "c:\myreports"
Apr 10 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

17
by: chicha | last post by:
Hey people, I have to convert MS Access 2000 database into mysql database, the whole thing being part of this project I'm doing for one of my faculty classes. My professor somehow presumed I...
20
by: John | last post by:
Hi, I've recently upgraded from Access 97 to Access 2002 & the performance basically stinks. I have tried the following items listed below but it has only had a minor impact: 1) Upgraded Jet...
1
by: Wayne Aprato | last post by:
I have a client who is running several Access 97 databases that I have written for them. They are about to upgrade to Access 2003. Is the default file format of Access 2003 still Access 2000 the...
4
by: JMCN | last post by:
object invalid or no longer set - confusion of the recordset in access 2003. i am currently converting from access 97 to access 2003. majority of the codes converted over perfectly fine, though...
2
by: Jeff | last post by:
Does anyone know of any potential problems running a 2000 database with 2003? Also, what about installing all other Office products as 2003 versions but leaving Access as 2002 running a 2000...
10
by: NEWSGROUPS | last post by:
I work for an organization that is migrating from Access 2000 to Access 2003. About 5 or 6 years ago we migrated from Access 97 to Access 2000 with no problem. Will I have trouble converting these...
17
by: Neil | last post by:
A client of mine likes some of the new bells and whistles in Access 2007, and is thinking about converting our A03 format MDB to an A07 format file. However, while some of the users have A07, many...
3
by: Roy Tong | last post by:
I maintain a shared database on Access 97. I've just tried converting a test copy of the database to 2003 and it appeared to work OK. That is I got no error messages. However then I look at my...
3
by: NEWSGROUPS | last post by:
I am in the midst of trying to convert about 25 Access 2000 to Access 2003. The new environment consists of Office/Access 2003 and Outlook 2003. When converting the back ends I have no problems....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
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...
0
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...
0
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...
0
jinu1996
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.