Copy link to clipboard
Copied
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"
...
Copy link to clipboard
Copied
Try using the Fields.ExecuteThisJavascript and use JavaScript to set the button's buttonPosition property, something like:
getField("buttonImage1").buttonPosition = position.IconOnly;
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
There is no property named ButtonLayout.
Copy link to clipboard
Copied
For what it's worth, there is indeed a ButtonLayout field property listed in the IAC documentation. It is supposed to do the same thing as the buttonPosition field property available to JavaScript. The point is you wouldn't use it with the jso object, but rather with a field object.
Copy link to clipboard
Copied
As Bernd explained, there is no property named buttonLayout, you need to use the buttonPosition position as indicated by George. However, if you want to use this directly from within VB/VBA - without using the "Fields.ExecuteThisJavascript" function, it needs to look this like (I usually assign fields to Object type variables, so that I can access them directly):
Dim btn As Object
Set btn = jso.getField("Image")
btn.buttonPosition = jso.Position.iconOnly ' <-- this is the syntax you need to use
MsgBox (jso.getField("Image").buttonPosition)
Find more inspiration, events, and resources on the new Adobe Community
Explore Now