Ms word 阅读Word中的隐藏文本
我使用以下方法来阅读隐藏文本Ms word 阅读Word中的隐藏文本,ms-word,vsto,Ms Word,Vsto,我使用以下方法来阅读隐藏文本 Globals.ThisAddIn.Application.ActiveDocument.Content.TextRetrievalMode.IncludeHiddenText = true; var Text = Globals.ThisAddIn.Application.ActiveDocument.Content.Text; 但它不会返回隐藏文本。此外,如果我选中TextRetrievalMode.IncludeHiddenText,它仍然是fals
Globals.ThisAddIn.Application.ActiveDocument.Content.TextRetrievalMode.IncludeHiddenText = true;
var Text = Globals.ThisAddIn.Application.ActiveDocument.Content.Text;
但它不会返回隐藏文本。此外,如果我选中TextRetrievalMode.IncludeHiddenText,它仍然是false——我的语句被忽略,但它不会引发任何异常
如何读取隐藏文本?像在您的示例中一样访问文本检索模式将始终返回具有默认配置的新的
范围
对象。您需要获取一个范围对象,在该对象上设置textrerievalmode
,然后从该对象获取文本:
var range = Globals.ThisAddIn.Application.ActiveDocument.Range();
range.TextRetrievalMode.IncludeHiddenText = true;
var text = range.Text;
访问示例中的文本检索模式将始终返回具有默认配置的新
范围对象。您需要获取一个范围对象,在该对象上设置textrerievalmode
,然后从该对象获取文本:
var range = Globals.ThisAddIn.Application.ActiveDocument.Range();
range.TextRetrievalMode.IncludeHiddenText = true;
var text = range.Text;