I feel like a fool..I put CUTE FTP in my last request for help --it should have been CUTE
PDF! I have FTP on my mind because I have been working on a web based application, and
somehow my brain got stuck on it..sorry!
Hi:
I need some help writing code that will "print" a report using Cute PDF.
Specifically, I need to set up a "Button" which, when clicked, will:
a. Create an PDF "Print" file of the report using Cute PDF. The file needs to be given a
unique name based on data that will be in the report and on the query that generates the
report.
b. Store the result in a predefined folder..
I really would appreciate some pointers as to how to do this using MS Access 2000. The
application will be running on W98, 2000 and WXP!
Thanks in advance for any help you can give me.
Regards
John Baker
--
Albert D. Kallal (MVP)
Edmonton, Alberta Canada
pleasenono...@msn.com
http://www.attcanada.net/~kallal.msn
Do you know if any of the other PDF writers support automation? If so which one? I gather
some version of Adobe does, but am uncertain how this works or which version.
Any follow up info you could provide would be appreciated. If I have to buy a PDF writer I
certainly want to support automation with it.
Best Regards
John Baker
>Do you know if any of the other PDF writers support automation? If so which one? I gather
>some version of Adobe does, but am uncertain how this works or which version.
There's a list of such Creating PDF files from within Microsoft Access
http://www.granite.ab.ca/access/pdffiles.htm
Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Thanks for that info.
Have you used PDFFactory that way? Are there detailed code instructions as to how to set
it up? I'm not highly skilled in VBA, and need a "cook book" to do things like that.
PDFFactory appears to be the least expensive solution that is capable of being controlled
through Access ($109.95), but I want to be certain I can set it up properly before I
invest in it.
Regards
John Baker
Best
John
Basically you are just setting registry values, and then your report can be preset to print to
PDFFactory (the basic version is only 49.95?)
Here is a function that I have used. I edited out some stuff specific to my use, and it calls some
registry functions from the Access Developers Handbook that I have not included(but you could
substitute any similar functions, there are many examples available on the net). Hopefully you can
get an idea of whats involved from this.
Private Function PrintToPDF()
'Purpose : uses a recordset to print individual reports to pdf files
'Comments : requires Fineprint PDF printer,
' and a report with Fineprint PDF printer set,
' selected items are written out to the selected items table
' a recordset is used to group the selected item on the appropriate field
' so that a seperate report can be printed.
'Parameters:
'Sets :
'Returns :
'Created by:
'Created : 03/25/2002 4:05:12 PM
'Modified : 03/25/2002 4:05:12 PM
On Error GoTo PrintToPDF_ERR
Dim dbs As Database
Dim rstFaxList As Recordset
Dim strSQL As String
Dim tblPickedItems As String
Dim strScheduleTable As String
Dim intFaxCount As Integer
Dim intFaxDone As Integer
Dim lngRetVal As adhRegErrors
Dim strRegValue As Variant
Dim strCurrentPDFOutput As String
Dim varCurrentPDFShowDlg As Variant
Dim strUserPDFOutput As String
Dim strDefOutputFile As String
Dim strNewOutputFile As String
'save users current default pdf output path
strRegValue = Space(adhcMaxDataSize)
lngRetVal = adh_accRegGetVal(adhcHKEY_CURRENT_USER, _
"Software\FinePrint Software\pdfFactory", _
"AutoSaveDir", strRegValue, Len(strRegValue))
If lngRetVal = adhcAccErrSuccess Then
strCurrentPDFOutput = strRegValue
Else
'no defined output, assume no pdf factory installed
MsgBox "You do not have PDF Factory installed, cannot print to PDF"
GoTo PrintToPDF_EXIT
End If
'save users current default pdf output view
strRegValue = Space(adhcMaxDataSize)
lngRetVal = adh_accRegGetVal(adhcHKEY_CURRENT_USER, _
"Software\FinePrint Software\pdfFactory\FinePrinters\FinePrint
pdfFactory\PrinterDriverData", _
"ShowDlg", strRegValue, Len(strRegValue))
If lngRetVal = adhcAccErrSuccess Then
varCurrentPDFShowDlg = Asc(Mid(strRegValue, 1, 1))
Else
'no defined output, assume no pdf factory installed
MsgBox "You do not have PDF Factory installed, cannot print to PDF"
GoTo PrintToPDF_EXIT
End If
'set output path for pdf files
strUserPDFOutput = GetPathPart_TSB(CStr(CurrentDb.Name)) & "PDF_" & CurrentUser() & "_" &
Format(Now(), "yyyymmdd_hhnnss")
MkDir strUserPDFOutput
lngRetVal = adh_accRegWriteVal( _
adhcHKEY_CURRENT_USER, _
"Software\FinePrint Software\pdfFactory", _
"AutoSaveDir", strUserPDFOutput, adhcREG_SZ)
If lngRetVal = adhcAccErrSuccess Then
'ok
Else
MsgBox "Unable to set required parameters, cannot print to PDF"
GoTo PrintToPDF_EXIT
End If
'set dialog mode to silent
lngRetVal = adh_accRegWriteVal( _
adhcHKEY_CURRENT_USER, _
"Software\FinePrint Software\pdfFactory\FinePrinters\FinePrint
pdfFactory\PrinterDriverData", _
"ShowDlg", 4, adhcREG_DWORD)
If lngRetVal = adhcAccErrSuccess Then
'ok
Else
MsgBox "Unable to set required parameters, cannot print to PDF"
GoTo PrintToPDF_EXIT
End If
'get recordset of sites to print
Set dbs = CurrentDb()
strSQL = "SELECT DISTINCT siteno From tblSites "
Set rstFaxList = dbs.OpenRecordset(strSQL, dbOpenSnapshot, dbReadOnly)
If Not rstFaxList.EOF And Not rstFaxList.BOF Then
rstFaxList.MoveLast
rstFaxList.MoveFirst
intFaxCount = rstFaxList.RecordCount
End If
intFaxDone = 0
' for each siteno in recordset
Do Until rstFaxList.EOF
'set output filename via pdfFacory key
'the key is erased by pdfFactory after file is created
'print report for siteno
strNewOutputFile = strUserPDFOutput & "\Site_Scheduler_Report(Site " & rstFaxList!siteno &
").PDF"
lngRetVal = adh_accRegWriteVal( _
adhcHKEY_CURRENT_USER, _
"Software\FinePrint Software\pdfFactory", _
"OutputFile", strNewOutputFile, adhcREG_SZ)
If lngRetVal = adhcAccErrSuccess Then
'ok
Else
MsgBox "Unable to set output file (" & strNewOutputFile & "), cannot print to PDF"
GoTo PrintToPDF_EXIT
End If
DoCmd.OpenReport "rptScheduler_PDF", acViewNormal, , "siteno = '" & rstFaxList!siteno & "'"
DoEvents
'there is some time lag between printing, and erasing the ouput file key
'loop here until outputfile key no longer found
strRegValue = Space(adhcMaxDataSize)
lngRetVal = adhcAccErrSuccess
Do Until lngRetVal <> adhcAccErrSuccess
DoEvents
lngRetVal = adh_accRegGetVal(adhcHKEY_CURRENT_USER, _
"Software\FinePrint Software\pdfFactory", _
"OutputFile", strRegValue, Len(strRegValue))
Loop
'next site
intFaxDone = intFaxDone + 1
rstFaxList.MoveNext
Loop
'restore user's pdf settings for default output path and show dialog
lngRetVal = adh_accRegWriteVal( _
adhcHKEY_CURRENT_USER, _
"Software\FinePrint Software\pdfFactory", _
"AutoSaveDir", strCurrentPDFOutput, adhcREG_SZ)
lngRetVal = adh_accRegWriteVal( _
adhcHKEY_CURRENT_USER, _
"Software\FinePrint Software\pdfFactory\FinePrinters\FinePrint
pdfFactory\PrinterDriverData", _
"ShowDlg", varCurrentPDFShowDlg, adhcREG_DWORD)
PrintToPDF_EXIT:
On Error Resume Next
If Not (rstFaxList Is Nothing) Then rstFaxList.Close: Set rstFaxList = Nothing
If Not (dbs Is Nothing) Then Set dbs = Nothing
Exit Function
PrintToPDF_ERR:
Select Case Err
Case 0 'insert Errors you wish to ignore here
Resume Next
Case Else 'All other errors will trap
Msgbox "Error: " & Err & ", " & Error,vbExclamation,"Error in PrintToPDF"
Resume PrintToPDF_EXIT
End Select
End Function
pdf995 stores output file name and folder info in an .ini file. All you need
to do is edit the .ini file in code. It's simple and very inexpensive..
One of my clients has used pdf995 from Access this way and had good things to
say about it.
I think it's a good solution. It's certainly the most cost-effective one
that I've found. Quality is acceptable. The only problem I've found is when
running under terminal services; there is only one .ini file - you can't
specify a different .ini file for each user, even if you have multiple
licenses. So you have to make sure only one person is generating pdf's at
any one time or else there can be a clash.
>Do you know if any of the other PDF writers support automation? If so which one? I gather
>some version of Adobe does, but am uncertain how this works or which version.
I use WIn2PDF and automate the generation of PDFs from both Access and
Excel, including assiging the file name, using Registry entries.
However, it does require Windows XP, NT, or 2000.
See
http://www.daneprairie.com/products/win2pdf.htm
Steven Zuch
Cogent Management Inc.
This sounds like a great solution.
Could someone give me a sample of the code that i would uise to edit the .ini file? I have
never done much in Code in Access, concentarting mosty on macros.
Thanks a lot
John
For example:
SaveSetting "Dane Prairie Systems", "Win2PDF", "PDFFileName", PathName
works just fine, but the commands that set the registry items are not
working. I pasted their code in, but when I call the routines:
SaveWin2PDFDword "file options", 0x02
It either does not work at all or says it's the wrong type. How do
you get the hex to work?
Their samples are VB, is that the problem? It would be great if
someone had some sample code similar to that which the earlier poster
put up for pdfFactory.
Thanks,
Tony
st...@nospam.com (Steve) wrote in message news:<40940ad0...@news.westnet.com>...
Our PDF and Mail Library for Access may be an option. It supports
outputting PDF files using any of the following drivers:
Adobe drivers (versions 3-6)
Win2PDF
pdfFactory
PDF 995
PDF 4 U
Amyuni PDF Converter
Certainly one could spend hours getting the programming right with any
particular driver, our library provides a quick, in-expensive solution to
"automate" output with any of those drivers, including securing files (PDF
Pro Plus edition), merging files, adding book marks etc. Code is as simple
as:
Const PDFENGINE_ADOBE_PDF = 2
Dim objPDF as New PDFClass
With objPDF
.ReportName = "Your Report"
.ReportWhere = "Some SQL Filter"
.PDFEngine = PDFENGINE_ADOBE_PDF
.OutputFile = "c:\some dir\some file.pdf"
.PrintImage
Debug.print .Result
End With
You'll find the library on our web site in the developer tools area.
--
Steve Arbaugh
ACG Soft
http://ourworld.compuserve.com/homepages/attac-cg
"John Baker" <Bake...@Verizon.net> wrote in message
news:de5390h3k2ipa7e8o...@4ax.com...