我想使用 C# 将一些文本写入现有的单词文本框。实际上什么也没发生,我不知道为什么。也许有人可以帮助我?
我的方法:
Microsoft.Office.Interop.Word.Application oWord = new Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word.Document oWordDoc = new Microsoft.Office.Interop.Word.Document();
void SearchTextBox(Microsoft.Office.Interop.Word.Document oDoc, string name, string newContent)
{
foreach (Microsoft.Office.Interop.Word.Shape shape in oDoc.Shapes)
{
if (shape.Name == name)
{
shape.TextFrame.TextRange.Text = newContent;
return;
}
}
}
称呼:
SearchTextBox(oWordDoc, "tbTest", "Please write some Text");