By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,880 Members | 2,443 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,880 IT Pros & Developers. It's quick & easy.

Access 2003: Converting .snp files to .pdf files

P: 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
Share this Question
Share on Google+
2 Replies


MMcCarthy
Expert Mod 10K+
P: 14,534
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
Expert 100+
P: 280
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

Post your reply

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