Dynamic change of list of values for a drop-down field in Word document with Aspose.Words for java

I’m new to Aspose and I want to implement the following functionality for a words document field:

  1. I have a field containing a drop down list of the Departments of a company.
  2. When I select one Company name, the field will change its list to show the Managers of that Department.
  3. Then, if I select one of the names, it is presented in the document.
  4. Now, the tricky part is, when I enter the same field one more, it will present again the list of Companies, and the sequence of steps continue as described above.

It’s a complex use case, but please let me know if this attainable with Aspose.Words.

@Zdimitris As far as I know there is no multilevel dropdown lists in MS Word documents. I think, the only way to achieve such behavior in MS Word document is using macros.
Aspose.Words is a document processing library and features you can implement in the output documents using Aspose.Words is limited to features supported by the target format itself. Using Aspose.Words you can work with macros in the document:
https://docs.aspose.com/words/java/working-with-vba-macros/
However, it would be easier to implement macros in MS Word and then use the created document as a template.
If it is requires to create such template programmatically using Aspose.Words, then please create the expected output document using MS Word and attach it here for our reference. We will investigate it and let you know how to create the same document using Aspose.Words.

Thank you @alexey.noskov for your assistance. It spares me much time of investigation and gives me guidelines how can I move in similar cases I’m investigating.
I am grateful for your effort to investigate this use case further.

1 Like

I have simplified the use case I described above as follows:
The dropdown list contains the departments, so the presentable text will be for example [Management, Procurement, Sales, IT], and let’s say that one selects “IT”, then the value will change to the name of the Manager - one name (e.g. “Dow Joe”).
I have created the list of all Departments (the presentable text) and for each member of the List I gave as value the name of one Manager. So, now the List contains the complete information, and the document will be created programmatically taking into account the VALUE of the pre-selected list.
All good up to now, BUT if the owner of the Word document wants to change that value, and changes to the “Sales” department, how this can be done with Aspose.Words?
I have not found how to give the ability to Word application to do it after the document is created by Aspose. From that point forward, there would be no logic to control the text presented: i.e. the value instead of the presented text.
The only solution I can think of is using a VB script, which is not preferable by the requirements
However, I’m a beginner to Aspose and there might be an advanced solution that avoids involvement of VB scripts.
Please, any help?

I’m attaching here a template document for your reference.
ThanksControlledList.docx (21.0 KB)

@Zdimitris Aspose.Words does not interact with MS Word UI, so I am afraid there is no way to implement custom logic using Aspose.Words, which will run upon interacting with document in MS Word.

You are right, your requirements of implementing interactive MS Word document can be implemented only using VB Script in MS Word. For example see the following vide that demonstrates how to implement dependent drop-down lists using VB Script:
https://www.youtube.com/watch?v=1Iw2-t8xNaQ

1 Like

It’s clear and final now. Now, I know the boundaries I can move within.
Thank you @alexey.noskov for your help.

1 Like