ListItems.SelectedValue is not filled for Dropdown and ComboBox StructuredDocumentTag

Hi,

I’m experimenting a bit with the posibilities of the StructuredDocumentTag. We need to be able to process changes made in Word with Aspose.Words. I’m currently using Aspose.Words .NET 11.7.

One of the things is we want, is to get the selected value of a dropdown or a combobox.
The listitems collection is correctly filled when we process the Word document in Aspose.Words. When we access ToTxt() on the SDT we get the selected text. However, the ListItems.SelectedValue is Nothing. I would expect the value of the selected item.
The same is true for the ComboBox type. I would expect the SelectedValue only to be empty if the user entered a new value in the combobox instead of selecting an existing one.

Could this be solved?

Regards,
Robert Wielink
Sr. Software Engineer
Infoland BV

Hi Robert,

Thanks for your query. I have tested the scenario and have not found any issue with StructuredDocumentTag. I have used the following code snippet with attached (SDTs.docx) document.

It would be great if you please share your document along with code for investigation purposes.

// Open document
Document doc = new Document(MyDir + "SDTs.docx");
foreach (StructuredDocumentTag sdt in doc.GetChildNodes(NodeType.StructuredDocumentTag, true, true))
{
    if (sdt.SdtType == SdtType.DropDownList)
    {
        SdtListItem secondItem = sdt.ListItems[2];
        sdt.ListItems.SelectedValue = secondItem;
        Console.WriteLine(sdt.ListItems.SelectedValue.Value);
    }
    else if (sdt.SdtType == SdtType.ComboBox)
    {
        SdtListItem secondItem = sdt.ListItems[1];
        sdt.ListItems.SelectedValue = secondItem;
        Console.WriteLine(sdt.ListItems.SelectedValue.Value);
    }
}
doc.Save(MyDir + "AsposeOut.Docx");

Hi,

If I set dropdown or combobox values with Aspose.Words, I can read the selectedvalue with Aspose.Words as you pointed out.

However, I open the document with the dropdown and combobox in Word 2010 and alter the selection using MS Word 2010. When I try to get the selected values set using MS Word 2010, it does not work. (SelectedValue is nothing)

In the attachment you will find 2 documents:
The document created with Aspose.Words, and the values set using Aspose.Words: asposetest.docx
The same document, but opened and changed in Word 2010: asposetestEdittedWithWord2010.docx

Note: I do see the selected values set with Aspose.Words in Word 2010. However, Aspose.Words does not seem to ‘understand’ the selectedvalues as set by MS Word 2010.

Regards,
Robert Wielink
Infoland BV

Hi Robert,

Thanks for sharing the details. I have managed to reproduce the same issue at my side. I have logged this issue as WORDSNET-6911 in our issue tracking system. I have linked this forum thread to the same issue and you will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-6911) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.