Hi, I have this working code to create a PDF document from a form. It works excellent.
What I am trying to do is create several documents vs one at a time. I have a form with all pertinent data but it is a Continuous Form say with 10 records in it.
I want to be able to generate a PDF with 10 pages or 10 PDFs one for each record on the form. Right now I have a button that when clicked runs the code below and creates the PDF that the form is currently focused on.
With the code below is there a way to accomplish this? or does anyone have any alternative solutions like a macro idea or something? Can I add some kind of loop code or something?
Many thanks.
Fen
Private Sub Command74_Click()
'DriveNow Lease PDF
'theDBguy@gmail.com
'4/10/2012
'This demo creates a XFDF file to merge with a fillable PDF form.
'Using this method avoids the need to use an Acrobat DLL to manipulate the PDF file.
'This method relies on the capabilities of the installed PDF reader.
'Declare the PDF file to be filled and assume it's in the same directory as the database
Const strPDF As String = "DN_Default_Letter_PDF_2016.pdf"
'Declare the XFDF file to use
Const strXFDF As String = "DN_Default_Letter_PDF_2016.xfdf"
Dim strPath As String
Dim intFile As Integer
strPath = "T:\CAM360_AUTOGEN_DOCUMENTS"
intFile = FreeFile
'Create XFDF file
Open strPath & "\" & strXFDF For Output As #intFile
Print #intFile, "<?xml version=""1.0"" encoding=""UTF-8""?>"
Print #intFile, "<xfdf xmlns=""http://ns.adobe.com/xfdf/"" xml:space=""preserve"">"
Print #intFile, "<f href=""" & strPDF & """/>"
Print #intFile, "<fields>"
Print #intFile, "<field name=""CUSTOMER"">"
Print #intFile, "<value>" & [Forms]![frm_Delinquency_Auto]![FullName] & "</value>"
Print #intFile, "</field>"
Print #intFile, "<field name=""ADDRESS"">"
Print #intFile, "<value>" & [Forms]![frm_Delinquency_Auto]![Address] & "</value>"
Print #intFile, "</field>"
Print #intFile, "<field name=""LEASEDATE"">"
Print #intFile, "<value>" & [Forms]![frm_Delinquency_Auto]![LoanDate] & "</value>"
Print #intFile, "</field>"
Print #intFile, "</fields>"
Print #intFile, "</xfdf>"
Close #intFile
'Open the PDF file
ShellEx strPath & "\" & strXFDF
End Sub
What I am trying to do is create several documents vs one at a time. I have a form with all pertinent data but it is a Continuous Form say with 10 records in it.
I want to be able to generate a PDF with 10 pages or 10 PDFs one for each record on the form. Right now I have a button that when clicked runs the code below and creates the PDF that the form is currently focused on.
With the code below is there a way to accomplish this? or does anyone have any alternative solutions like a macro idea or something? Can I add some kind of loop code or something?
Many thanks.
Fen
Private Sub Command74_Click()
'DriveNow Lease PDF
'theDBguy@gmail.com
'4/10/2012
'This demo creates a XFDF file to merge with a fillable PDF form.
'Using this method avoids the need to use an Acrobat DLL to manipulate the PDF file.
'This method relies on the capabilities of the installed PDF reader.
'Declare the PDF file to be filled and assume it's in the same directory as the database
Const strPDF As String = "DN_Default_Letter_PDF_2016.pdf"
'Declare the XFDF file to use
Const strXFDF As String = "DN_Default_Letter_PDF_2016.xfdf"
Dim strPath As String
Dim intFile As Integer
strPath = "T:\CAM360_AUTOGEN_DOCUMENTS"
intFile = FreeFile
'Create XFDF file
Open strPath & "\" & strXFDF For Output As #intFile
Print #intFile, "<?xml version=""1.0"" encoding=""UTF-8""?>"
Print #intFile, "<xfdf xmlns=""http://ns.adobe.com/xfdf/"" xml:space=""preserve"">"
Print #intFile, "<f href=""" & strPDF & """/>"
Print #intFile, "<fields>"
Print #intFile, "<field name=""CUSTOMER"">"
Print #intFile, "<value>" & [Forms]![frm_Delinquency_Auto]![FullName] & "</value>"
Print #intFile, "</field>"
Print #intFile, "<field name=""ADDRESS"">"
Print #intFile, "<value>" & [Forms]![frm_Delinquency_Auto]![Address] & "</value>"
Print #intFile, "</field>"
Print #intFile, "<field name=""LEASEDATE"">"
Print #intFile, "<value>" & [Forms]![frm_Delinquency_Auto]![LoanDate] & "</value>"
Print #intFile, "</field>"
Print #intFile, "</fields>"
Print #intFile, "</xfdf>"
Close #intFile
'Open the PDF file
ShellEx strPath & "\" & strXFDF
End Sub