I have an excel file which has several columns with headers such as name,year,country,organization. I want to loop through each row and send the value to pdf. I am using kofax PDF plus for this task. Below is the excel file format and code. The range value should be variable it should loop from second row as first row contains headers and pass data to PDF and save it by their first and last name.
>>> use code - tags <<<
Last Name | First Name | Organization | track ID | Country | Year |
ABC | XYZ | DL123 | 12345 | USA | 2019 |
TZY | CVX | AN156 | 12234 | France | 2015 |
ULO | SXA | RT990 | 65728 | India | 2018 |
>>> use code - tags <<<
Code:
Sub copytopdf()
Dim strPDFPath As String
Dim objJSO As Object
Dim strPDFOutPath As String
Dim PowerApp As App
Dim PowerDVDoc As DVDoc
Dim PowerDDDoc As DDDoc
Dim jso As Object
Dim wb As Workbook
Dim Saveas As Variant
Dim fdObj As Object
Dim SavedFilePath As String
Dim PDFPath As String
Dim Path As String
PDFPath = "C:\Users\anilpujar\Desktop\workdoc.pdf"
Set PowerApp = CreateObject("NuancePDF.App")
Set PowerDVDoc = CreateObject("NuancePDF.DVDoc")
PowerDVDoc.Open (PDFPath)
Set PowerDDDoc = PowerDVDoc.GetDDDoc
Set jso = PowerDDDoc.GetJSObject
jso.getField("Last Name").Value = Range("G2").Value
jso.getField("First Name").Value = Range("F2").Value
jso.getField("Country").Value = Range("M2").Value
jso.getField("Year").Value = Range("N2").Value
Path = "C:\Users\anilpujar\Desktop\"
SavedFilePath = PowerDDDoc.Save(DDSaveFull, Path & Last Name & First Name & ".pdf")
End Sub
Last edited by a moderator: