I've been looking and googling around for 4h to find a solution for my problem.

I'm trying to set the text of an defined rich text content control. For test purposes i defined just one content control (rich text) in the document where i would like to change the text.

var docx = Application.Documents.Open(@"D:\BaseDocs\Test.docx");
var all = GetAllContentControls(docx); // Returns all content controls in active document
var one = all.First(); // Select first one --> works
((RichTextContentControl)one).Text = "Test" //Trying to set text --> invalid cast exception

I can't set the value of this predefined content control. Any help is really appreciated.

没有正确的解决方案

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top