更新时间:2023-12-06 16:36:58
您好,
我有下载了你的项目,但我仍然想知道你如何在项目中使用该表格?
I have downloaded your project but I'm still wondering how do you use the form in the project?
我认为这个过程是获取文本 - >获取控制对象 - >设置文本到控件对象,对吗? 哪个部分代码让你感到困惑?
I think the process is Getting the text->Getting the control object->Setting the text to the control object, right? Which part code puzzles you?
我认为关键点可能是如何访问richtextcontentcontrol。如果是这样,我建议你为控件设置一个标签,例如"Test"。然后你可以使用
SelectContentControlByTag 返回对象然后将文本设置为对象的方法。
I think the key point maybe how to access the richtextcontentcontrol. If so, I would suggest you set a tag for the control, such as "Test". And then you could use SelectContentControlByTag method to return the object and then set text to the object.
这是一个简单的代码。
//not sure how would you get the document object, you could get it by your way
Word.Document wdDoc = Globals.ThisDocument.Application.ActiveDocument;
Word.ContentControl contentControl = wdDoc.SelectContentControlsByTag("Test")[1];
contentControl.Range.Text = "This is added text string";
***的问候,
Terry