C# Microsoft Interops Word将注释插入表格单元格崩溃Word

C# Microsoft Interops Word将注释插入表格单元格崩溃Word,c#,.net,ms-word,interopservices,C#,.net,Ms Word,Interopservices,我希望使用Microsoft.Interop.word以编程方式打开word文档,并在表格单元格中插入注释。 我有单元格范围的起始和结束位置。(Range.Start\Range.End) 当insert comment Word崩溃时我将您的代码转换为pascal,并进行一些更改工作正常,没有错误! 看到了吗 文字崩溃?没有错误消息?Word安装是否正确?Word的哪个版本?请为您的问题添加答案!Microsoft Word 2013,Word安装正确,无错误消息,无异常,只需崩溃“Micro

我希望使用Microsoft.Interop.word以编程方式打开word文档,并在表格单元格中插入注释。 我有单元格范围的起始和结束位置。(Range.Start\Range.End)


当insert comment Word崩溃时

我将您的代码转换为pascal,并进行一些更改工作正常,没有错误! 看到了吗


文字崩溃?没有错误消息?Word安装是否正确?Word的哪个版本?请为您的问题添加答案!Microsoft Word 2013,Word安装正确,无错误消息,无异常,只需崩溃“Microsoft Word已停止工作”,然后重新启动Microsoft Word。如果我在平面文本处插入注释,它将在Interops Versione 14.0.0.0中正常工作
Application.ActiveDocument.Select(); // select ative document
Range rg = Application.Selection.Range; // get the range of the current selection (all document)


 if (rg.Tables.Count > 0)
 {

     Microsoft.Office.Interop.Word.Range rngTab = rg;

     //set the coordinate of the Range of the text 
     rngTab.Start = startRng;
     rngTab.End = endRng;


     doc.ActiveWindow.Visible = true;
     rg.Select();
     Application.ActiveDocument.Comments.Add(rngTab, ref commentText);                                           
  }
var WApplication:twordapplication; rg,rngTab:range;
commentText:olevariant;
begin
commentText:='123';
WApplication := twordapplication.Create(form1);
WApplication.Connect;
WApplication.Visible:=true;
WApplication.Activate;
rg:= WApplication.Selection.Range; // get the range of the current selection (all document)
rngTab:= rg;
     //set the coordinate of the Range of the text
     rngTab.Start:= 1;
     rngTab.End_:= 2;
     rg.Select();
     WApplication.ActiveDocument.Comments.Add(rngTab, commentText);// add comment to text
     rngtab:=WApplication.ActiveDocument.Tables.Item(1).cell(2,2).range;
     rngtab.Select();
     WApplication.ActiveDocument.Comments.Add(rngTab, commentText); // add comment to cell in the table
end;