Discussion:
pdDoc.Save 0, FileNm won't save!
(too old to reply)
ABG Laura
2023-08-10 21:51:52 UTC
Permalink
I have an Adobe PDF fillable form. I make a copy of the master form and save it with the name of the client in the user's folder. I fill out the form with data from the database. Then I use:

pdDoc.Save 0, FileNm 'File Name
pdDoc.Close

Every single time when it gets to pdDoc.Close it prompts to save and asks for the file name even though I already told it the file name. I've included my code below though it might not be clear. I've done extensive searching for the correct answer and gotten nada. Apparently I'm the first person it has ever happened to. I'm getting frustrated. Thanks so much for looking at it.

Laura

Code
******

Private Sub cmdFormFillTest_Click()

On Error GoTo Err_cmdGenProposal_Click


Dim fs
Set fs = CreateObject("Scripting.FileSystemObject")


Dim db As Database
Dim rst As Recordset

Set db = CurrentDb
Set rst = db.OpenRecordset("tmpContactFormFill")



fs.CopyFile "I:\Data\Contact Info Change Form.pdf", "c:\users\" & atCNames(1) & "\data\" & Me.PlanName & " Contact Change Form.pdf"


Dim FileNm, gApp, avDoc, pdDoc, jso

FileNm = "c:\users\" & atCNames(1) & "\data\" & Me.PlanName & " Contact Change Form.pdf" 'File location

Set gApp = CreateObject("AcroExch.app")

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

jso.GetField("Plan name").Value = "" & Me.PlanName
jso.GetField("Plan Account Number").Value = "" & Me.PlanNumber


If rst.RecordCount <> 0 Then
With rst
.MoveFirst
jso.GetField("Plan Role").Value = "" & rst.Fields(2)
jso.GetField("Name").Value = "" & rst.Fields(3)
jso.GetField("Company Name").Value = "" & rst.Fields(7)
jso.GetField("Title").Value = "" & rst.Fields(6)
jso.GetField("Address").Value = "" & rst.Fields(4) & ", " & rst.Fields(5)
jso.GetField("Phone").Value = "" & rst.Fields(8)
jso.GetField("Email").Value = "" & rst.Fields(9)
'more stuff after this as it cycles through the table

End With
End If

pdDoc.Save 0, FileNm


pdDoc.Close

'The file does open with the name I gave it and it is filled out, but when I ask it to close, it prompts to save and the file name is gone. The save box opens and asks where do you want to save .pdf? (no file name even though I sent one).




End If

Set gApp = Nothing
Set avDoc = Nothing
Set pdDoc = Nothing
Set jso = Nothing

Exit_cmdGenProposal_Click:
Exit Sub

Err_cmdGenProposal_Click:
MsgBox Err.Description
Resume Exit_cmdGenProposal_Click
end sub
ABG Laura
2023-08-11 15:21:39 UTC
Permalink
It was this flag:
Protected Mode has to be off (Preferences - General - Security (Enhanced))
Loading...