This is my first time using VBA and I am trying to use it to fill out 1,000 forms from an Excel spreadsheet. I watched a video on youtube and was able to fill the form out with this code but is there a way to modify this to pull from my excel spreadsheet?
I need
Business = Column A
Address = Column B
Zipcode = Column C
FEIN = Column D
I need it to fill out one form for each record then save that PDF file as the Business name (Field: Business)
I really hope someone is able to help! We are a small development agency that is trying to distribute a grants to small businesses that have been effected by COVID and we have little man power. Thank you in advance!
Code
Sub write_to_pdf_form_from_Excel()
Dim pdfApp As Acrobat.AcroApp
Dim pdfDoc As Acrobat.AcroAVDoc
Dim Support_doc As Acrobat.AcroPDDoc
Dim pdf_form As AFORMAUTLib.AFormApp
Dim Address As AFORMAUTLib.Field
Dim Business As AFORMAUTLib.Field
Dim FEIN As AFORMAUTLib.Field
Dim Zipcode As AFORMAUTLib.Field
Set pdfApp = CreateObject("AcroExch.App")
Set pdfDoc = CreateObject("AcroExch.AvDoc")
If pdfDoc.Open(pdf_form_file, "") = True Then
pdfDoc.BringToFront
pdfApp.Show
Set pdf_form = CreateObject("AFORMAUT.App")
Set Address = pdf_form.Fields("BusinessAddress")
Set Business = pdf_form.Fields("BusinessName")
Set FEIN = pdf_form.Fields("FEIN")
Set Zipcode = pdf_form.Fields("Zipcode")
With Sheet1
Business.Value = "Pretend Biz"
Address.Value = "123 Street"
Zipcode.Value = "12345"
FEIN.Value = "1234567"
End With
Set Support_doc = pdfDoc.GetPDDoc
If Support_doc.Save(PDSaveFull, "G:\GIS_Maps\Small Business Grant 2020\CBI\Filled Out\Output.pdf") Then
Debug.Print "Saved"
Else
Debug.Print "Failed to Save"
End If
pdfDoc.Close True
Support_doc.Close
pdfApp.Exit
Set Business = Nothing
Set Address = Nothing
Set Zipcode = Nothing
Set FEIN = Nothing
Set pdfDoc = Nothing
Set Support_doc = Nothing
End If
End Sub
Display More