VBA to PDF Form Fields - preserve value format (1 Viewer)

grahma_aiken

Registered User
Joined
Apr 18, 2012
Messages
10
I have a VBA procedure (Access 2016) that writes to form fields in a PDF file. One of the fields is a zip code, and one of the values I need to send is a zip code beginning in 0. The preceding 0 keeps getting dropped. The form field format category property is set to none, and I can manually type in the zip code with the proceeding zero with no error or formatting change in the PDF.

I have tried Dim Zip as String and Zip = "02110" with the same result. I have tried Cstr("02210") with the same result. I have tried to send a ' before the value and got a Type mismatch error. I have tried to set the form field format category property to Zip Code and get a Type mismatch error. Help!!??

Here is the part that isn't working:

Set AcroApp = CreateObject("AcroExch.App")
Set theForm = CreateObject("AcroExch.PDDoc")
StartDoc "F:\SomePDFDoc.PDF"
theForm.Open (strDoc)
Set jso = theForm.GetJSObject

Dim Field1 As String

Set Field1 = jso.getfield("8")

Field1.Value = "02210"
 

Ranman256

Registered User
Joined
Apr 9, 2015
Messages
3,429
mismatch means it cannot be a string. It must be set to a numeric value.
 

grahma_aiken

Registered User
Joined
Apr 18, 2012
Messages
10
mismatch means it cannot be a string. It must be set to a numeric value.
I'm not sure I follow you Ranman256. I have other fields in the same PDF with the same properties that I pass strings to without error. I do not get an error when I pass the value as a string either by definition or through expression, it just drops the leading zero. Can you show me what you mean?
Thank you!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom