我正在使用Microsoft.Office.Interop打开,处理和保存Word文档文件(.doc)。 我可以获取所有文本内容,但在打开的Word文档中加载添加的控件(即TextBoxes)时无法成功。如何加载添加到Word文档的所有控件(Microsoft Office Interop Word)?
我使用下面的命令
Microsoft.Office.Interop.Word.ApplicationClass oWordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
Microsoft.Office.Interop.Word.Document oWordDoc = oWordApp.Documents.Open(ref fileName, ref missing, ref readOnly, ref missing,ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing);
oWordDoc.Activate();
oWordApp.Selection.TypeParagraph();
string test = oWordDoc.Content.Text;
获取文本我如何可以访问所有的对照包括基地word文档中?
谢谢。
感谢@Ramin,但oWordDoc.Shapes.Count()等于零! –
我明白了,使用oWordApp.Selection.WholeStory()而不是oWordApp.Selection.TypeParagraph()并使用您的解决方法取得了诀窍。 –