Word.Application.Selection.Find.Execute 不适用于 Word 2013
Word.Application.Selection.Find.Execute does not work with Word 2013
我有以下已成功用于 Word 2010 的互操作代码:
Microsoft.Office.Interop.Word.Application wordApp=new Microsoft.Office.Interop.Word.Application();
object readOnly = false;
object isVisible = false;
object trueValue = true;
Word.Document document = wordApp.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 trueValue, ref missing, ref missing, ref missing);
object matchCase = true;
object matchWholeWord = true;
object matchWildCards = false;
object matchSoundsLike = false;
object matchAllWordForms = false;
object forward = true;
object format = false;
object matchKashida = false;
object matchDiacritics = false;
object matchAlefHamza = false;
object matchControl = false;
object read_only = false;
object visible = true;
object replace = 2;
object wrap = 1;
wordApp.Selection.Find.Execute(ref findText, ref matchCase, ref matchWholeWord,
ref matchWildCards, ref matchSoundsLike, ref matchAllWordForms, ref forward,
ref wrap, ref format, ref replaceWithText, ref replace,
ref matchKashida, ref matchDiacritics, ref matchAlefHamza, ref matchControl);
现在我安装了 Word 2013,但该应用程序不再有效。我收到此消息(已翻译):
An unhandled exception of type
'System.Runtime.InteropServices.COMException' occurred in
ReadWordFiles.exe
Additional information: This method or property is not available,
because this command can not be used for reading.
他们好像把它撕掉了。
我现在应该用什么代替以前的方法?
信不信由你,错误消息意味着我尝试搜索的文件是只读的。
如果我更改文件属性,它可以正常工作。逻辑...
我有以下已成功用于 Word 2010 的互操作代码:
Microsoft.Office.Interop.Word.Application wordApp=new Microsoft.Office.Interop.Word.Application();
object readOnly = false;
object isVisible = false;
object trueValue = true;
Word.Document document = wordApp.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 trueValue, ref missing, ref missing, ref missing);
object matchCase = true;
object matchWholeWord = true;
object matchWildCards = false;
object matchSoundsLike = false;
object matchAllWordForms = false;
object forward = true;
object format = false;
object matchKashida = false;
object matchDiacritics = false;
object matchAlefHamza = false;
object matchControl = false;
object read_only = false;
object visible = true;
object replace = 2;
object wrap = 1;
wordApp.Selection.Find.Execute(ref findText, ref matchCase, ref matchWholeWord,
ref matchWildCards, ref matchSoundsLike, ref matchAllWordForms, ref forward,
ref wrap, ref format, ref replaceWithText, ref replace,
ref matchKashida, ref matchDiacritics, ref matchAlefHamza, ref matchControl);
现在我安装了 Word 2013,但该应用程序不再有效。我收到此消息(已翻译):
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in ReadWordFiles.exe
Additional information: This method or property is not available, because this command can not be used for reading.
他们好像把它撕掉了。
我现在应该用什么代替以前的方法?
信不信由你,错误消息意味着我尝试搜索的文件是只读的。
如果我更改文件属性,它可以正常工作。逻辑...