' Copyright (c) 2021 ActivePDF, Inc. ' ActivePDF Toolkit 2018 ' Example generated 03/04/21 Dim FSO, strPath, intOpenOutputFile, strSQL, _ strConn, intLoadDBMapFile, intDBToForm ' Get current path Set FSO = CreateObject("Scripting.FileSystemObject") strPath = FSO.GetFile(Wscript.ScriptFullName).ParentFolder & "\" Set FSO = Nothing ' Instantiate Object Set oTK = CreateObject("APToolkit.Object") ' Create the new PDF file intOpenOutputFile = oTK.OpenOutputFile(strPath & "new.pdf") If intOpenOutputFile <> 0 Then ErrorHandler "OpenOutputFile", intOpenOutputFile End If ' Specify the template form to populate oTK.SetDBInputTemplate strPath & "dbtemplate.pdf" ' Set query command to a variable strSQL = "Select * From Supplier" ' Set connection String to a variable strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strPath & "xtreme.mdb" & ";Persist Security Info=False" ' Set master query oTK.SetMasterQuery strConn, "Admin", "", -1, strSQL ' Set the row Separator oTK.SetDBMultiRowSeparator "" ' Related query separator is only needed if different from default of '|' oTK.RelatedQuerySeparator = "|" ' Add related query oTK.AddRelatedQuery strConn, "Admin", "", -1, strSQL, true ' If db column names are different then field names a map file is needed ' In this example only the zip/postal code is different intLoadDBMapFile = oTK.LoadDBMapFile(strPath & "dbformmap.txt") If intLoadDBMapFile <> 0 Then ErrorHandler "LoadDBMapFile", intLoadDBMapFile End If ' Flatten fields that are populated with data oTK.SetDefaultDBMergeFlag -997 ' Flatten all other fields on the form oTK.FlattenRemainingFormFields = 1 ' Fill the template form intDBToForm = oTK.DBToForm(false) If intDBToForm <> 0 Then ErrorHandler "DBToForm", intDBToForm End If ' Clear and close used queries oTK.ClearQueries ' Close the output file oTK.CloseOutputFile ' Release Object Set oTK = Nothing ' Process Complete Wscript.Echo("Done!") ' Error Handling Sub ErrorHandler(method, outputCode) Wscript.Echo("Error in " & method & ": " & outputCode) End Sub