My Assistant
![]() ![]() |
|
|
Feb 17 2012, 02:08 PM
Post
#1
|
|
|
UtterAccess Veteran Posts: 480 From: Omaha, NE |
Hi guys it's a been a while since I've posted any questions here. I'm stuck and I know someone will be able to figure this out.
I've been using Leban's "report to pdf" code for years to convert Access snapshot reports to PDF documents. One of my users has several PDF documents that get generated at one time because they are separate reports (ie. Cover page, Main Letter, Detail Sheet.....). They cannot be combined into a single report in Access so they are asking if I can combine the PDF files into a single PDF document. The PDF files are all output to a single folder. Of course if each of the users had Adobe Professional they could manually combine the PDF files but that could get expensive purchasing licenses. And ultimately I would like this to be an automated process. Any suggestions? Thank you in advance for your help! This post has been edited by brett_hinman: Feb 17 2012, 02:10 PM |
|
|
|
Feb 17 2012, 02:20 PM
Post
#2
|
|
|
UtterAccess VIP Posts: 1,451 |
Perhaps you should look into using PDF Creator. I believe you can do this sort of thing with it using pure VBA.
|
|
|
|
Feb 17 2012, 02:56 PM
Post
#3
|
|
|
UtterAccess Veteran Posts: 480 From: Omaha, NE |
Daniel I appreciate the quick response. I'll keep your suggestion in mind. The application has been in use for several years and I'm trying not to make a lot of major changes to it. I was hoping to find a solution that will keep the application in tact as-is.
Any other suggestions or solutions would be appreciated. Thank you! Brett |
|
|
|
Feb 18 2012, 02:38 AM
Post
#4
|
|
|
UtterAccess Member Posts: 22 |
|
|
|
|
Feb 18 2012, 08:18 AM
Post
#5
|
|
|
Utter A-fishin'-ado Posts: 17,723 From: Cincinnati, Ohio, USA . . . ><((((°> |
The latest version of the ReportToPDF has merging document functionality built-in:
' Version 7.75 ' Added Merge function to merge 2 PDF documents Ex: CODE Private Sub cmdMerge_Click()
Dim blRet As Boolean ' Call our Merge function ' Please note the PDF doc passed as the second param is merged into the PDF doc passed as the first param. ' For testing purposes: Dim sMaster As String Dim sChild As String sMaster = "C:\test1.pdf" sChild = "C:\test2.pdf" blRet = MergePDFDocuments(sMaster, sChild) MsgBox "How did we do:" & blRet End Sub |
|
|
|
Feb 19 2012, 01:55 AM
Post
#6
|
|
|
UtterAccess Ruler Posts: 1,807 From: SoCal, USA |
hi Walter, i've been using Lebans' ReportToPdf for several years in A97 to print Access reports to PDF files - works great, of course. today i tried Stephen's MergePDFDocuments for the first time, still in A97. it works beautifully - if the two PDF files are in the same folder as the database where the code is running. otherwise, i keep getting an error message that the strStorage.dll can't be found.
i've tried copying the two PDF files to the same folder that the db is in, using FileCopy, before calling the merge code. same error msg. i've tried DoEvents after the FileCopy calls and before the merge code call, same error msg. i've tried Dev Ashish's sSleep code in place of DoEvents, same error msg. no matter what i've tried, the Lebans code only works for me if the PDF files are already in the same folder that the current db is in. have you had better luck? do you have any suggestions for me? thx, tina |
|
|
|
Feb 19 2012, 03:01 AM
Post
#7
|
|
|
UtterAccess VIP Posts: 6,898 From: Earth... |
Tina, I've used Leban's code for merging, will look into 'original' folder issue. Its been awhile since I made the clients app. Hope we figure it out. (IMG:style_emoticons/default/thumbup.gif) |
|
|
|
Feb 19 2012, 07:59 AM
Post
#8
|
|
|
Utter A-fishin'-ado Posts: 17,723 From: Cincinnati, Ohio, USA . . . ><((((°> |
Hi Tina. Are you passing in the full path to the PDF files? I use that feature regularly and I do not recall any issues with it needing to be in the same folder as the DB.
Here's a sample of how I use it: CODE Private Sub SendCommentatorAsPDF_Click()
Const ReportPath As String = "C:\Projects\Commentator\Reports" Const PDFName As String = "Commentator.pdf" Dim PrelimFlag As String If Dir(ReportPath & "\*.pdf") <> "" Then Kill ReportPath & "\" & "*.pdf" End If If Me.Preliminary Then PrelimFlag = " - PRELIMINARY" End If Call SaveAsPDF("rptCommentatorSummary", ReportPath & "\rptCommentatorSummary.pdf", ReportPath & "\" & PDFName) Call SaveAsPDF("rptBenchmarks", ReportPath & "\rptBenchmarks.pdf", ReportPath & "\" & PDFName) Call SaveAsPDF("rptGrossCollectionRate", ReportPath & "\rptGrossCollectionRate.pdf", ReportPath & "\" & PDFName) 'Call SaveAsPDF("rptPatientCollectionEfficiency", ReportPath & "\rptPatientCollectionEfficiency.pdf", ReportPath & "\" & PDFName) Call SaveAsPDF("rptDaysInAR", ReportPath & "\rptDaysInAR.pdf", ReportPath & "\" & PDFName) Call SaveAsPDF("rptAROver90Days", ReportPath & "\rptAROver90Days.pdf", ReportPath & "\" & PDFName) Call SaveAsPDF("rptChargesHeldCredentialing", ReportPath & "\rptChargesHeldCredentialing.pdf", ReportPath & "\" & PDFName) Call SaveAsPDF("rptChargesHeldBilling", ReportPath & "\rptChargesHeldBilling.pdf", ReportPath & "\" & PDFName) Call SaveAsPDF("rptLagDays", ReportPath & "\rptLagDays.pdf", ReportPath & "\" & PDFName) Call SaveAsPDF("rptDenialsRegistration", ReportPath & "\rptDenialsRegistration.pdf", ReportPath & "\" & PDFName) Call SaveAsPDF("rptDenialsAll", ReportPath & "\rptDenialsAll.pdf", ReportPath & "\" & PDFName) Call SaveAsPDF("rptCreditBalances", ReportPath & "\rptCreditBalances.pdf", ReportPath & "\" & PDFName) Call SaveAsPDF("rptCreditsRunning12Months", ReportPath & "\rptCreditsRunning12Months.pdf", ReportPath & "\" & PDFName) Call SaveAsPDF("rptMissingCharges", ReportPath & "\rptMissingCharges.pdf", ReportPath & "\" & PDFName) Call SaveAsPDF("rptPayorMix", ReportPath & "\rptPayorMix.pdf", ReportPath & "\" & PDFName) Call SaveAsPDF("rptPayorMixRunning12Months", ReportPath & "\rptPayorMixRunning12Months.pdf", ReportPath & "\" & PDFName) Call SendMail("Commentator Reports for " & Left(Me.PostPeriod, 4) & "-" & Mid(Me.PostPeriod, 5, 2) & PrelimFlag, ReportPath & "\" & PDFName) Me.Status = "Finished" End Sub Private Sub SaveAsPDF(ReportName As String, Filename As String, Optional MergeIntoFileName As String) Me.Status.Visible = True Me.Status = "Creating PDF: " & ReportName Me.Repaint ConvertReportToPDF ReportName, vbNullString, Filename, False, False If Nz(MergeIntoFileName) <> "" Then Me.Status = "Combining PDF: " & ReportName Me.Repaint Call MergePDFDocuments(MergeIntoFileName, Filename) End If End Sub |
|
|
|
Feb 19 2012, 12:35 PM
Post
#9
|
|
|
UtterAccess Ruler Posts: 1,807 From: SoCal, USA |
thanks, Aqua and Walter, for responding. :) i hope we can figure it out, too! i am passing the full filepaths as arguments. i've been running the db from a flash drive (32GB, with plenty of free space), so i tried running it from my hard drive, just in case that was the issue - but no joy.
here's the "original" code i wrote, before i added code to copy the PDF files to the db folder before merging. it gives me the same error msg as the "enhanced" (haha) code: 53 - File not found: StrStorage.dll. the only time it works is when the PDF files that i select are already in the db folder, and then it works like a charm. hopefully y'all will find something stupid i've done and overlooked, and the story will have a happy ending! CODE Private Sub isMergePDFs()
If MsgBox("First, choose the file you want to merge, " _ & "and then choose the file you want to add it to." _ & vbCr & vbCr & "NOTE that the second file will be " _ & "saved immediately, WITH THE SAME NAME. " _ & "So if you want the original file intact, " _ & "make a copy of it before you start!" _ & vbCr & vbCr & "Do you want to start now?", _ vbExclamation + vbYesNo + vbDefaultButton1, _ "INSTRUCTIONS") = vbYes Then Dim strChild As String, strMaster As String, bln As Boolean strChild = ahtCommonFileOpenSave(, , , , , , _ "Choose the PDF file you want to merge...", , True) If isValidateEntry(strChild) = False Then Exit Sub strMaster = ahtCommonFileOpenSave(, , , , , , _ "Choose the PDF file you want to add the first file to...", , True) If isValidateEntry(strMaster) = False Then Exit Sub bln = MergePDFDocuments(strMaster, strChild) If bln Then If MsgBox("Do you want to open the merged PDF file now?", _ vbExclamation + vbYesNo + vbDefaultButton2, _ "Last question!") = vbYes Then FollowHyperlink strMaster End If Else MsgBox "The merge failed. Recommend that you open " _ & "both PDF files to verify that both are unchanged.", _ vbCritical, "ACTION FAILED" End If End If End Sub Private Function isValidateEntry(ByVal str As String) As Boolean Dim bln As Boolean bln = True If str = "" Then bln = False ElseIf Not (Right(str, 4) = ".pdf") Then MsgBox "You didn't choose a PDF file. Please start over.", _ vbCritical, "INVALID FILE TYPE" bln = False ElseIf Dir(str) = "" Then MsgBox "The file name that you entered in the dialog box " _ & "does not exist. Please start over." & vbCr _ & "Choose an existing PDF file, and " _ & "do NOT rename it.", vbCritical, "INVALID FILE NAME" bln = False End If isValidateEntry = bln End Function |
|
|
|
Feb 19 2012, 01:30 PM
Post
#10
|
|
|
UtterAccess VIP Posts: 6,898 From: Earth... |
Tina,
The following code is on clients app's command button that uses mergePDFs: CODE [/code] Private Sub Command21_Click() On Error GoTo Err_Command21_Click Dim blRet As Boolean ' Call our Merge function ' Please note the PDF doc passed as the second param is merged into the PDF doc passed as the first param. ' For testing purposes: Dim sMaster As String Dim sChild As String sMaster = "N:\employeepdfs\" & Me.ExistingFile & ".pdf" sChild = "N:\employeepdfs\" & Me.NewFile & ".pdf" blRet = MergePDFDocuments(sMaster, sChild) MsgBox "Files Have Been Merged To Existing File Name:" Exit_Command21_Click: Exit Sub Err_Command21_Click: MsgBox Err.Description Resume Exit_Command21_Click End Sub [code] The database FE's reside on workstations c:\database1\ folder, and the BE is on the server's N:\DataApp_BE folder. As you see above the PDFs are in a seperate folder on the N:\ drive, as their scanner is programable, and the scanned items automatically go there. All the *.Dll's associated with the merge/create PDF's reside in the Windows\System32 folder on the work stations. NO changes were made to the function. It works fine in A2003 & A2007 & its Runtime. (Sorry, I don't have A97 anymore.) Hope it helps, |
|
|
|
Feb 19 2012, 02:29 PM
Post
#11
|
|
|
UtterAccess Ruler Posts: 1,807 From: SoCal, USA |
hi Aqua, thanks for responding. :)
the only difference i note is that you're storing the dlls in the System32 folder, while i've always put them in the same folder (on the user's hard drive) that holds the FE db. Stephen's documentation says that either location is appropriate, and doesn't lean to one or the other as being preferable, as far as i could tell. hopefully Walter will weigh in again, with something that will point out where i'm going wrong. i can see the potential of this function being very useful to my db's users - of which i am one - so i really hope there is some way to straighten out the problem. tina |
|
|
|
Feb 19 2012, 04:30 PM
Post
#12
|
|
|
Utter A-fishin'-ado Posts: 17,723 From: Cincinnati, Ohio, USA . . . ><((((°> |
I had to VPN in to work to see how mine is set up ... I copied the StrStorage.DLL into the SYSTEM32 folder, like Aqua.
Do you have the latest versions of the code and of the DLLs? Per the site: QUOTE Change search order for DynaPDF.DLL and StrStorage.DLL - now searches the folder your MDB resides in before searching System32 folder. You MUST replace StrStorage.DLL, DynaPDF.DLL and modReportToPDF in your own MDB before calling the new functions. If so, and if it still doesn't work, try putting a copy of the DLLs in the SYSTEM32 folder, just to see if it will work then. Let us know how it goes... |
|
|
|
Feb 19 2012, 05:16 PM
Post
#13
|
|
|
UtterAccess VIP Posts: 6,898 From: Earth... |
Tina,
I'm like you, I agree the DLLs can be either DB folder or System32 folder. Its just a habit I have had, I put ALL DLLs in system folder by default. Like Niesz said, ck the updated versions of all to use the MergePdfs function. After you do that and it still dosen't work, copy/move the DLL's to system32 folder to test. If it still dosen't work, it must be related to A97. With the BP Horizon issue in the Gulf of Mexico, the new federal requirements for certifications on employees offshore became really 'tight' issue. Leban's MergePDFs saved me & clients a lot of work, time in proof of certification requirements. Good luck, and like you I'd like to find cause of issue! (IMG:style_emoticons/default/notworthy.gif) <Hope's Stephen is enjoying retirement & his grandkid's/family> |
|
|
|
Feb 19 2012, 06:16 PM
Post
#14
|
|
|
UtterAccess Ruler Posts: 1,807 From: SoCal, USA |
hi Aqua and Walter, thanks for responding. :)
i was pretty sure i had the newest versions of the DLLs, from 2009; i downloaded again from Lebans.com, just to be safe. still no joy, so i copied the DLLs into the System32 folder, as you both suggested...and then the code ran, partial hallelujah! i say partial because i'll have to see if my company's IT dept will allow the files to be added to to that folder on the PCs at work. and in fact i'll need their help to push the files, if they agree - because i don't think i'll be running around to 50 or 60 computers to do it manually! i think i'm going to roll all my code changes into a clean copy of the FE db, just in case i have a corruption problem, then test again. if it still won't run without the DLLs in the System32 folder, then i'll do a final test at work next week, just in case the problem is in my home PC. if i still need the System32 folder for success, then i'll tackle the IT guys! thanks for the help, both of you! tina |
|
|
|
Feb 19 2012, 06:19 PM
Post
#15
|
|
|
UtterAccess VIP Posts: 6,898 From: Earth... |
|
|
|
|
Feb 21 2012, 10:33 AM
Post
#16
|
|
|
UtterAccess Member Posts: 26 |
I use PDFToolkit from www.accesspdf.com ... bob
|
|
|
|
Feb 21 2012, 10:34 AM
Post
#17
|
|
|
UtterAccess Member Posts: 26 |
Also note that Lebans PDF creator doesn't work in Access 2010.
|
|
|
|
Feb 23 2012, 10:18 AM
Post
#18
|
|
|
UtterAccess Veteran Posts: 480 From: Omaha, NE |
Wow it looks like this post was able to help a few other people too. Awesome!
The code is very simple and worked right out of the gate. I did notice that I had to place the DLL files in the system32 folder. It did not work when I left the files in the same folder as the MDB file as I did before. While this is fantastic and will merge 2 files I actually need to merge up to 5 PDF files. I suppose I could create some sort of loop that adds the "child" files to the "master" file. Thank you all very much for your help. |
|
|
|
Feb 23 2012, 10:39 AM
Post
#19
|
|
|
Utter A-fishin'-ado Posts: 17,723 From: Cincinnati, Ohio, USA . . . ><((((°> |
If you take a look at the code I posted, it combines about 14 PDFs. You should be able to easily use a loop to do the same with an unlimited number.
|
|
|
|
Feb 23 2012, 11:42 AM
Post
#20
|
|
|
UtterAccess VIP Posts: 6,898 From: Earth... |
Brett, Glad you have it working!!!! (IMG:style_emoticons/default/thumbup.gif) Good luck with your project(s)!!!! |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 19th May 2013 - 06:01 AM |