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

VBA - Acrobat DC Pro - AFormAut - PopulateListOrComboBox

New Here ,
Jun 14, 2016 Jun 14, 2016

Copy link to clipboard

Copied

Hi,

I'm trying to fill a combobox with wsh (or vba).

I get an error "Invalid arguments" when calling PopulateListOrComboBox.

Can you help for the correct syntax ?

I tried with 1 or 2 arguments.

Ex code:

Sub Test()

    Dim oAcrobat

    Dim oAVDoc

    Dim oForm

    Dim arr

    Dim arr2

    Dim oField

    Set oAcrobat = CreateObject("AcroExch.App")

    Set oAVDoc = CreateObject("AcroExch.AVDoc")

    Set oForm = CreateObject("AFormAut.App")

  

    oAVDoc.Open "C:\Dev\KExtAcrobat\ak.pdf", "ak.pdf"

  

    arr = Array("1", "2")

    arr2 = Array("1", "2")

  

    Set oField = oForm.Fields.Item("Dropdown1")

  

    oField.PopulateListOrComboBox arr, arr2

  

    Set oField = Nothing

  

    Set oAcrobat = Nothing

    Set oAVDoc = Nothing

    Set oForm = Nothing

End Sub

TOPICS
Acrobat SDK and JavaScript

Views

2.0K

Translate

Translate

Report

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

correct answers 1 Correct answer

LEGEND , Jun 14, 2016 Jun 14, 2016

It's a bit more tedious, but you can always do something like:

Dim oAcrobat

Dim oAVDoc

Dim oForm

Set oAcrobat = CreateObject("AcroExch.App")

Set oAVDoc = CreateObject("AcroExch.AVDoc")

Set oForm = CreateObject("AFormAut.App")

oAVDoc.Open "C:\Dev\KExtAcrobat\ak.pdf\ak.pdf", "ak.pdf"

oForm.Fields.ExecuteThisJavascript "getField('Dropdown1').setItems([['1', 'ExpVal1'], ['2', 'ExpVal2']])"

Set oForm = Nothing

Set oAVDoc = Nothing

Set oAcrobat = Nothing

I seem to recall a problem with using PopulateListOrComboBo

...

Votes

Translate

Translate
LEGEND ,
Jun 14, 2016 Jun 14, 2016

Copy link to clipboard

Copied

PopulateListOrComboBox does not appear in my documentation. how do you come to use it?

Votes

Translate

Translate

Report

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
New Here ,
Jun 14, 2016 Jun 14, 2016

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

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 ,
Jun 14, 2016 Jun 14, 2016

Copy link to clipboard

Copied

Thank you, I was looking in the wrong place (JavaScript Fields object, not IAC OLE Fields object).

This segment looks OK,

   arr = Array("1", "2")

    arr2 = Array("1", "2") 

    Set oField = oForm.Fields.Item("Dropdown1") 

    oField.PopulateListOrComboBox arr, arr2

and seems match the documentation where each of the arguments is "an array of strings". However, I don't know VB/VBA to be sure that this matches. I also suggest double checking that the field name is exactly as given, and it really is a list or combo box.

Votes

Translate

Translate

Report

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
New Here ,
Jun 14, 2016 Jun 14, 2016

Copy link to clipboard

Copied

Thank you for the reply.

Yes field name is ok and is a combobox (Msgbox oField.Type).

I tried to add a field and fill it and get the same error when calling PopulateListOrComboBox (wrong argument or call of procedure):

The field "test" is well created.

oForm.Fields.Add "test", "combobox", 0, 0, 800, 100, 810

Set oField = oForm.Fields.Item("test")

oField.PopulateListOrComboBox arr, arr2

Have you another suggestion ?

Votes

Translate

Translate

Report

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 ,
Jun 14, 2016 Jun 14, 2016

Copy link to clipboard

Copied

It's a bit more tedious, but you can always do something like:

Dim oAcrobat

Dim oAVDoc

Dim oForm

Set oAcrobat = CreateObject("AcroExch.App")

Set oAVDoc = CreateObject("AcroExch.AVDoc")

Set oForm = CreateObject("AFormAut.App")

oAVDoc.Open "C:\Dev\KExtAcrobat\ak.pdf\ak.pdf", "ak.pdf"

oForm.Fields.ExecuteThisJavascript "getField('Dropdown1').setItems([['1', 'ExpVal1'], ['2', 'ExpVal2']])"

Set oForm = Nothing

Set oAVDoc = Nothing

Set oAcrobat = Nothing

I seem to recall a problem with using PopulateListOrComboBox from a long time ago, but can't locate any useful info now. I switched to using Fields.ExecuteThisJavaScript for most things long ago because it just works better. You can define variables and functions in folder-level or document-level JavaScripts to make it easier to manage.

Votes

Translate

Translate

Report

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
New Here ,
Jun 15, 2016 Jun 15, 2016

Copy link to clipboard

Copied

LATEST

Thank you George !

Special but it does the job.

Votes

Translate

Translate

Report

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