Kath Pelletti
kp at sdsonline.net
Fri Jun 30 02:27:52 CDT 2006
Vlad - I have done something similiar using pdf995 as the pdf printer. You have to buy the p9fedit995 version as opposed to pdf995 version. Rather than describe it, I (hope no-one minds) that I have pasted the content of an old email from John Ruff to me on this subject. Like John, I have found their support to be great and the autoname function great. The only hassle is the need to install the printer on each PC and also set the autoname function on each PC. Here it is: -------------------------------------------------------------------------------- Kath, I have successfully used pdf's pdf995 and pdfEdit995 (www.pdf995.com) to prevent the dialog box from popping up. I too went to them for the answer and they promptly replied. I think pdf995 and pdfEdit995 are great tools and for the cost of $20.00 USD for the entire suite, quite inexpensive. Here is my response with code to a similar question posted on p2p.wrox.com' vba_Access newsgroup. After purchasing the products and playing with them, I asked pdf for assistance in creating a pdf file automatically. Here is my original request and their response. (They responded within 24 hours.) Subject: Automatically Generating a PDF File Through MS Access I recently purchased your Suite License. I am trying to create a pdf file automatically through MS Access. My report has PDF995 as it's printer and when I go to print the report via code, the Save As dialog box pops up asking me what directory to save it in and what file name. Is there a way that I can programatically tell the program which directory and file name to use? The followng code will automatically print the report when I press a button on a form when I have the Printer set to a Printer and not PDF995. Dim strDir As String Dim strFile As String strDir = "C:\Documents and Settings\John\My Documents\My Work\PDF Report Files\" strFile = Format(Now(), "hh-nn") & ".pdf" DoCmd.OpenReport "rptBirthdays", acViewNormal How can I have the program automatically create the pdf file and place it in the strDir directory with the strFile name. Here is their response: John, PdfEdit has autoname features. I recommend setting the PDF to be named based on the document being printed. Create a temporary report with the name of the PDF you want and tell it to print to PDF995. The Save As dialog won't appear. -pdf995 Support And here is my final coding to create the pdf file: Private Sub cmdPrint_Click() ' If you don't want the report dialog box being displayed ' asking what name you want to give the pdf report, you will ' need pdfEdit995. With pdfEdit995 you tell pdf995 what directory ' and what file name to initially give the pdf report. ' ' Quote from PDF; "pdfEdit995 has autoname features. I recommend setting ' the PDF to be named based on the document being printed. Create a ' temporary report with the name of the PDF you want and tell it to ' print to PDF995. The Save As dialog won't appear." Dim strDir As String Dim strFile As String Dim fOK As Boolean ' Directory to place the PDF files that are to ' be printed strDir = "C:\Documents and Settings\John\My Documents\My Work\PDF Report Files\" ' Name of file to create strFile = Format(Now(), "hh-nn") & ".pdf" ' Create the report DoCmd.OpenReport "rptBirthdays", acViewNormal ' Copy the created file (name is Output.pdf) to the ' directory and file name specified above fOK = CopyFile_TSB(strDir & "Output.pdf", strDir & strFile) ' If the file didn't copy properly, tell the user If Not fOK Then Beep MsgBox "File Copy Failure" End If End Sub Function CopyFile_TSB(strSource As String, strDestination As String) As Boolean ' Comments : copies a file ' Parameters: strSource - source file ' strDestination - destination file ' Returns : True if successful, False otherwise ' Const BufferSize = 4096 Dim strBuffer As String * BufferSize Dim strTempBuffer As String Dim intSourceFile As Integer Dim intDestinationFile As Integer Dim lngCounter As Long On Error GoTo PROC_ERR intSourceFile = FreeFile Open strSource For Binary As #intSourceFile intDestinationFile = FreeFile Open strDestination For Binary As #intDestinationFile For lngCounter = 1 To LOF(intSourceFile) \ BufferSize Get #intSourceFile, , strBuffer Put #intDestinationFile, , strBuffer Next lngCounter lngCounter = LOF(intSourceFile) Mod BufferSize If lngCounter > 0 Then Get #intSourceFile, , strBuffer strTempBuffer = Left$(strBuffer, lngCounter) Put #intDestinationFile, , strTempBuffer End If Close #intSourceFile Close #intDestinationFile CopyFile_TSB = True PROC_EXIT: Exit Function PROC_ERR: CopyFile_TSB = False Resume PROC_EXIT End Function I know this sounds like a commercial for pdf, but when I find software that works well I like to let others know. John ----- Original Message ----- From: ACTEBS To: Access Developers discussion and problem solving Sent: Friday, June 30, 2006 4:08 PM Subject: [AccessD] Save Files to PDF Hi Everyone, I have a small application that merges DB info to Various Word documents. What I would like to do is be able to save those Word Docs as PDF files so they can be emailed. The problem I see after reading heaps of info on the internet, is that the save as dialogue box will pop up asking what name you wish to save the resultant PDF file to. Is it possible to get around this? The other issue is not all users have Adobe Acrobat PDF printers on their machine. Some have free versions of PDF creators so we need to be able to allow the user to select the PDF printer to use. I hope I have explained myself enough for you guys to understand what I'm trying to achieve. Any help, or links would be greatly appreciated. Vlad -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com