Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Word.Application.Selection.Find.Execute不适用于Word 2013_C#_Ms Word_Interop - Fatal编程技术网

C# Word.Application.Selection.Find.Execute不适用于Word 2013

C# Word.Application.Selection.Find.Execute不适用于Word 2013,c#,ms-word,interop,C#,Ms Word,Interop,我有以下已成功用于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.Docume

我有以下已成功用于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,该应用程序不再工作。我收到这条信息(翻译):

类型的未处理异常 中出现“System.Runtime.InteropServices.COMException” ReadWordFiles.exe

其他信息:此方法或属性不可用, 因为此命令不能用于读取

看来他们把它撕了

我现在应该使用什么来代替前一种方法?

信不信由你,错误消息意味着我试图搜索的文件是只读的。


如果我更改文件属性的,它将正常工作。逻辑…

信不信由你,花了两天时间才确定这是导致问题的原因。感谢you@Gowtham.K.Reddy很高兴它能帮助你:)