问题
We are attempting to fill out a Adobe PDF form using, ms access and the Acrobat objects. I have cut to the relevant snippets. We are able to fill out most fields successfully, with the exception of fields (which should be strings), that have leading zeros (like a zip code). The code below shows the problem.
'Initialize Acrobat by creating the App object.
Set objAcroApp = CreateObject("AcroExch.App")
< snip >
'Create the AVDoc object.
Set objAcroAVDoc = CreateObject("AcroExch.AVDoc")
'Set the PDDoc object.
Set objAcroPDDoc = objAcroAVDoc.GetPDDoc
'Set the JS Object - Java Script Object.
Set objJSO = objAcroPDDoc.GetJSObject
< snip >
objJSO.getfield("Zip Code").Value = "02110"
The Adobe form is filled out BUT the leading 0 inn the zip code is dropped.
回答1:
A reliable way to make sure that preceeding zeroes are kept is to force a string. A simple way to do this is to add a space character to the string looking like a number, and it will then be rendered properly.
There may be implications if the form is used to submit back some data.
But if you don't have control over the form, that's what you have at hand.
来源:https://stackoverflow.com/questions/27552439/filling-in-adobe-form-with-ms-access-field-is-dropping-leading-zeros