i want open a word document programmatically using Microsoft.Interop.Word and insert a comment into a table cell. I have the start and End position of Range of the cell. (Range.Start \ Range.End)
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);
}
When insert comment Word Crashes
I convert your code to pascal with some changes. It work fine, without error! See it