Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Why is Field's ButtonLayout property unavailable in VBA?

Guest
Dec 20, 2016 Dec 20, 2016

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"

...

TOPICS
Acrobat SDK and JavaScript
907
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 20, 2016 Dec 20, 2016

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

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 21, 2016 Dec 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 21, 2016 Dec 21, 2016

There is no property named ButtonLayout.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 21, 2016 Dec 21, 2016
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 21, 2016 Dec 21, 2016

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)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines