2017-02-07 9 views
0

Я пытаюсь запустить образец в Visual Studio инструменты для офиса, но когда я пытаюсь запустить его, Excel дает эту ошибку:C# Visual Studio инструменты для офиса дает эту ошибку: Excel работает с проблемами с надстройкой X

Excel is running into problems with the X add-in. If this keeps happening disable this add-in and check for available updates 

Мой код, как показано ниже:

private void btnA2P_Click(object sender, RibbonControlEventArgs e) 
     { 
      Microsoft.Office.Interop.Excel.Range currentFind = null; 
      Microsoft.Office.Interop.Excel.Range firstFind = null; 

      Microsoft.Office.Interop.Excel.Range AllWords = Globals.ThisAddIn.Application.get_Range("A1", "B3");    

      currentFind = AllWords.Find("a", Type.Missing, 
     Microsoft.Office.Interop.Excel.XlFindLookIn.xlValues, Microsoft.Office.Interop.Excel.XlLookAt.xlPart, 
     Microsoft.Office.Interop.Excel.XlSearchOrder.xlByRows, Microsoft.Office.Interop.Excel.XlSearchDirection.xlNext, false, 
     Type.Missing, Type.Missing); 

      while (currentFind != null) 
      { 
       currentFind.Replace(currentFind.Value, currentFind.Value.ToString().Replace("a", "b"));     

       if (firstFind == null) 
       { 
        firstFind = currentFind; 
       }  

       else if (currentFind.get_Address(Microsoft.Office.Interop.Excel.XlReferenceStyle.xlA1) 
         == firstFind.get_Address(Microsoft.Office.Interop.Excel.XlReferenceStyle.xlA1)) 
       { 
        break; 
       } 

       currentFind.Font.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red); 
       currentFind.Font.Bold = true; 

       currentFind = AllWords.FindNext(currentFind); 
      } 
     } 

Кроме того, когда я хочу, чтобы отладить код он возвращает нуль из метода Find

ответ

0

метод Find возвращает null, если совпадение не найдено.

Какая строка кода вызывает проблему с подключаемым модулем? О каком плагине вы говорите?