Free Support Forum - aspose.com

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.

<!–[if gte mso 9]>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:HyphenationZone>21</w:HyphenationZone>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>PL</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>AR-SA</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:DontVertAlignCellWithSp/>
<w:DontBreakConstrainedForcedTables/>
<w:DontVertAlignInTxbx/>
<w:Word11KerningPairs/>
<w:CachedColBalance/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
<m:mathPr>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:dispDef/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
</m:mathPr></w:WordDocument>
<![endif]–><!–[if gte mso 10]>

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin-top:10.0pt; mso-para-margin-right:0cm; mso-para-margin-bottom:10.0pt; mso-para-margin-left:47.9pt; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:Arial; mso-bidi-theme-font:minor-bidi;}

<![endif]–>

// 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.