I want to change of a ContentControl using Word.Interop. It works with a ContentControl of Type Text. But it fails with a ContentControl of type wdContentControlDropdownList. Error message something like "You are not allowed to change because the field is protected".
Is there any way to change the active item of a DropDownList?
private void setstatus(string status)
{
ContentControls ccList;
ccList = this.activeDocument.SelectContentControlsByTitle("Status");
ContentControl cc = ccList[1];
// works with wdContentControlText
// fails with wdContentControlDropdownList
cc.Range.Text = status;
}
Finally I found a working solution.
private void setstatus(string value)
{
ContentControls ccList;
ccList = activeDocument.SelectContentControlsByTitle("Status");
ContentControl cc = ccList[1];
// search all list entries and select the required item
foreach (ContentControlListEntry ccl in cc.DropdownListEntries)
{
if (ccl.Text == value)
{
ccl.Select();
break;
}
}
}