Hello. This is my first post so hopefully following the rules.
I am trying to create a vba macro that:
1. Open a PDF template
2. Populate the fields
3. Save PDF with a new name to desired location
4. Close the PDF template
So far I managed to run steps 1,2.4
I'd really appreciate if I can get assistance with respect to step 3
I tried to implement the AcroExch.PDDoc.save() Method but keep
BTW, I wouldn't mind to save in a different way if possible.
Thanks in advance.
Code
Dim AcrobatApplication As Acrobat.CAcroApp
Dim AcrobatDocument As Acrobat.CAcroAVDoc
Dim PdfDoc As Acrobat.CAcroPDDoc
Dim Fcount As Long
Dim sFieldName As String
On Error Resume Next
Set AcrobatApplication = CreateObject("AcroExch.App")
Set AcrobatDocument = CreateObject("AcroExch.AVDoc")
Set PdfDoc = AcrobatDocument.GetPDDoc()
If AcrobatDocument.Open("C:\Users\ilotvin001\Desktop\VBA Tests\Excel to PDF\1test.pdf", "") Then
AcrobatApplication.Show
Set Acroform = CreateObject("AFormAut.App")
Set Fields = Acroform.Fields
Fcount = Fields.Count
For Each Field In Fields
row_number = row_number + 1
sFieldName = Field.Name
Sheet2.Range("B" & row_number + 1) = Field.Name
Sheet2.Range("C" & row_number + 1) = Field.Value
Sheet2.Range("D" & row_number + 1) = Field.Style
Next Field
Else
MsgBox "Failure"
End If
PdfDoc.Save PDSaveFull, "C:\Users\ilotvin001\Desktop\VBA Tests\Excel to PDF\New"
AcrobatApplication.CloseAllDocs
'AcrobatApplication.Exit 'Why do we need to exist from all the below?
Set AcrobatApplication = Nothing
Set AcrobatDocument = Nothing
Set Field = Nothing
Set Fields = Nothing
End Sub
Display More