Skip to main content
December 20, 2016
Question

Why is Field's ButtonLayout property unavailable in VBA?

  • December 20, 2016
  • 1 reply
  • 1014 views

My code is fairly standard, if people need to see more I can provide but essentially I am just trying to access a field's ButtonLayout property. I know the field I am accessing is a button, b/c I Added it previously in the code and I can review it once the file saves. The last line below is the one that doesn't work. I get the error "Object doesn't support this property or method". I am using MS Access 2016 with the Adobe Acrobat 10.0 Type Library. In contrast I can access the Value, and the BorderStyle properties and set them just fine. The lines in green work, the line in red does not work. Why? I've tried not using capitals and camel case. No difference.

...

Set pdDoc = avDoc.GetPDDoc()

Set jso = pdDoc.GetJSObject

jso.getField("buttonImage1")..BorderStyle = "beveled"

jso.getField("buttonImage1").buttonImportIcon CStr(photoSet!Photo)

jso.getField("caption1").Value = CStr(photoSet!Caption)

jso.getField("buttonImage1").ButtonLayout = "1"

...

This topic has been closed for replies.

1 reply

Inspiring
December 21, 2016

Try using the Fields.ExecuteThisJavascript and use JavaScript to set the button's buttonPosition property, something like:

getField("buttonImage1").buttonPosition = position.IconOnly;

December 21, 2016

I was able to instantiate the fields object and use the Fields.ExecuteThisJavascript method and it didn't work. Also, in the long run this will open up a new issue because my field names are being named and values are being assigned dynamically and I would have to be able to pass a variable defined in VBA to the JS function, which I am not sure can be done.

Using the FIelds object I was able to tap into the ButtonLayout property. However it only works for the first call. On the second call I get an error "Method 'Item' of object 'IFields' failed.

Not sure if it is because this is all happening in a loop so I am going to attempt to use it outside of the loop now.

Bernd Alheit
Community Expert
Community Expert
December 21, 2016

There is no property named ButtonLayout.