• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

Cannot save changes to PDF from VBA

New Here ,
Dec 07, 2021 Dec 07, 2021

Copy link to clipboard

Copied

Hi 

Hope someone can give me a hent to get past this problem.

Im opening af PDF form template, inserting a value and want to save it as a copy with another name.

But the change deos not get saved.

 

My code is like this:

 

Private Sub MakeS11Files()

Dim FileTemplate, FileNmCopy, gApp, avDoc, pdDoc, jso

FileTemplate = "C:\TestFolder\S-11.PDF" 'File location
FileNmCopy = "C:\TestFolder\S-11_Copy.PDF"
FileCopy FileTemplate, FileNmCopy 'Copying the original template for edithing
Set gApp = CreateObject("AcroExch.app")

Set avDoc = CreateObject("AcroExch.AVDoc")
If avDoc.Open(FileNmCopy, "") Then
Set pdDoc = avDoc.GetPDDoc()
Set jso = pdDoc.GetJSObject

Debug.Print jso.getField("Text1").Value 'TEST in Immediate window show original name

Set x = jso.getField("Text1")
x.Value = "Bing Crosby"

Debug.Print jso.getField("Text1").Value 'TEST in Immediate window show Bing Crosby

pdDoc.Save PDSaveFull, FileNmCopy 'Save changes to the PDF document
pdDoc.Close

End If

Debug.Print jso.getField("Text1").Value 'TEST in Immediate window still show Bing Crosby

 

'Close the PDF; the True parameter prevents the Save As dialog from showing
avDoc.Close (True) 'The new file it generate but when I open it, it's still the original name. The process of closing the document is like abording the changes


'Some cleaning
Set gApp = Nothing
Set avDoc = Nothing
Set pdDoc = Nothing
Set jso = Nothing

End Sub

TOPICS
Acrobat SDK and JavaScript , Windows

Views

91

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 08, 2021 Dec 08, 2021

Copy link to clipboard

Copied

What version of Adobe Acrobat does you use?

Does you use a XFA form?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 08, 2021 Dec 08, 2021

Copy link to clipboard

Copied

LATEST
Im using Adobe Acrobat DC

Soren Isaksen

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines