Announcement

Collapse
No announcement yet.

Unable to write data to PDF using FoxitPhantomPDF with VBA Macro

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Unable to write data to PDF using FoxitPhantomPDF with VBA Macro


    I have a simple pdf form where I can enter some text. I want to enter the text to the pdf using a macro. I currently use Foxit Phantom PDF Reader. But the macro is somehow is unable to write to the pdf. I have followed the API docs. But unable to get through. Am I missing something? A small help would be appreciated.

    I'm using Foxit PhantomPDF trial version: 9.1.0.5096 Link to sample pdf : http://www.royale-marketing.com/wp-c...sample_pdf.pdf

    API docs : http://cdn01.foxitsoftware.com/pub/f...munication.pdf

    Below is the macro.

    Function MyPdf()
    Dim phApp As PhantomPDF.Application
    Dim phFormDoc As PhantomPDF.Document
    Set phApp = CreateObject("PhantomPDF.Application")
    Set phFormDoc = phApp.OpenDocument("C:\sample_pdf.pdf", "", True, True)
    Call phFormDoc.SetFieldValue("Name", "John Doe")
    Call phFormDoc.Save phFormDoc.Save
    End Function
    Last edited by Sripadraj; 06-29-2018, 04:55 AM.

  • #2
    lyndi_wu


    Thanks, but I see the macro execute this line

    Set phFormDoc = phApp.OpenDocument("C:\sample_pdf.pdf", "", True, True)

    where the foxit application opens the pdf document, but not this ?

    Call phFormDoc.SetFieldValue("Name", "John Doe")

    Does that still mean VBA is not supported now?
    Last edited by Sripadraj; 06-29-2018, 10:53 AM.

    Comment


    • #3
      Sripadraj

      Sorry for misunderstanding your issue, We have tested your marco, after change to the below marco, it is working on the VBA environment, please try the below one in your VBA environment.
      Sub MyPdf()
      Dim phApp As PhantomPDF.Application
      Dim phFormDoc As PhantomPDF.Document
      Set phApp = CreateObject("PhantomPDF.Application")
      Set phFormDoc = phApp.OpenDocument("C:\sample_pdf.pdf", "", True, True)
      Call phFormDoc.SetFieldValue("Name", "John Doe")
      Call phFormDoc.Save
      End Sub

      If it does not work, please help to ensure that you have configured the VBA environment correctly, you can re-configure VBA by referring to the guidance "Work with PhantomPDF via VBA scripts in Excel" in the user manual of Foxit PhantomPDF.




      Comment

      Working...
      X