Microsoft Interops Word Insert Comment into Table Cell Crash Word

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

--------------Solutions-------------

I convert your code to pascal with some changes. It work fine, without error! See it

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;

Category:c# Time:2018-12-29 Views:13

Related post

  • Inserting comments into a cell 2013-07-10

    *VAC 2010+12.00 *VAC 2010+12.00 *VAC 2010+12.00 I insert a comment into a cell. When completed and the curser is run over the comment icon teh text box appears hundreds of rows below the cell and the text box itself has collapsed. Any thoughts? -----

  • insert image into table cell in javascript 2013-06-07

    I want to insert images to the new cell created .How can i do. Can anyone guide me in doing it. Here's my code to insertcells <!DOCTYPE html> <html> <head> <script> function displayResult() { var firstRow=document.getElementBy

  • how do I insert a comment into a cell 2014-05-26

    How do I insert a comment into a cell? --------------Solutions------------- rt click on the cell to bring up the context menu Hi, Sadly you can't insert any comments in a cell using Starter Edition, you need to upgrade it to full version. http://www.

  • How best to insert a graphic into table cells? 2013-10-24

    Hi, I need to use the Autotext (building blocks) feature to insert a graphic into table cells. A macro is going to be used to accomplish this. How can I save the graphic in the autotext feature so that it comes into the table cells appropriately? Sho

  • How to insert drop-down-list into table cell? 2014-12-15

    Is it possible to insert drop-down-list into table cell? Thank you! Here is some of the code: $sql_query="SELECT nameOfwarning FROM warnings"; $sodss=mysqli_query($d,$sql_query); if (mysqli_num_rows($result)<1) ?> <select name = "warnings"

  • How to insert data into table 2012-04-12

    I need to know how to insert data into table. For example (Table - students info) : No | Student Name | Address | Phone Number 1. | Add | | Add - is a hyperlink. The user need to click Add(hyperlink) to add student. After the user click Add, then thi

  • Extract data in a cell comment into a cell? 2013-10-27

    I have a spreadsheet that has cell comments and I need to get the text and values that are in these comments into a cell. Is this possible? --------------Solutions------------- > .. is it possible to have each comment go into it's own cell? Try th

  • Formatting the Inserted Comment of a Cell 2014-03-02

    I'm using Excel 2007 and I know how to (i) insert a comment into a cell, and (ii) how to format said comment. What I can't figure out—and I know I have done this the past—is how to delete or change the colour of the drop shadow of the comment. Every

  • Trying to INSERT values into tables that contain FOREIGN KEYS that reference each other 2014-05-26

    So i'm trying to make a database based off a spec sheet (was given an ER diagram and a DB Schema) and said sheet specifies that the first two table contain references to each other, like so: WAREHOUSE Column name Data type Comments warehouseID VARCHA

  • How to find and replace text inside a table cells in word document? 2015-01-29

    Hi, In a word document table, I need to find the text Orange, Grapes & Guava in column 2 and update the text in corresponding cell in column for the same row as “Like”. Col 1 Col 2 Col 3 Apple Like Orange Dislike Grapes Dislike Blue Berry Dislike

  • Is it possible to disable index from function while inserting records into table and enable otherwise 2011-12-14

    Is it possible to disable index from oracle function while inserting records into table and enable it once insertion completed ? --------------Solutions------------- If your indexes are constraints based i.e. primary key, unique key you can disable o

  • Insert data into tables linked with foreign key 2012-01-13

    First of all I tried this Insert Data Into Tables Linked by Foreign Key and didn't get the answer. I have 3 tables: Table: Customers ID -------LastName-------FirstName-------PhoneNumber Table: Order ID-------Status-------CustomerID Table: OrderLine I

  • How to Insert a Newline into a Table Cell in Word? 2010-04-30

    when i insert '\r\n' into a cell of a table in word document using c# ,it does not work ,why ? how to do it ? Word.Application wordApp; Word.Document wordDoc; filePath = @"" + strWorkPath + @"Uploads\Template\template.doc"; saveFilePath = @"" + strWo

  • Inserting backgrounds into select table cells in word 2010 2012-08-08

    Hi, I need help in how to insert a background image into select cells into a an Avery template. Here's what I'm trying to do: I am printing labels with a coloured background (that is an image) on 8 1/2 x 11" paper. there are 50 labels per sheet. Temp

  • How to programmatically insert comments into a Microsoft Word document? 2009-02-20

    Looking for a way to programmatically insert comments (using the comments feature in Word) into a specific location in a MS Word document. I would prefer an approach that is usable across recent versions of MS Word standard formats and implementable

  • Insert row into table alphabetically on a certain cell 2011-06-21

    I am using jQuery to insert rows into a table after a database insert. When the page loads the table is ordered alphabetically on a particular cell (see below). When I insert a new row using jQuery I would like to be able to insert it alphabetically

  • User insert data into specific cell in an HTML table using PHP 2011-11-28

    Is it possible to specify the coordinates of an HTML table cell, x and y? If it is possible, then how can a user insert a value into that specified cell by submitting a form? Or is there a better way to do this? Thanks --------------Solutions--------

  • How to insert a graphic into table cells 2013-03-04

    I need to have 1 graphic image in each table cell and each table cell also needs to accommodate text. The graphic needs to be at the top of the cell and the text needs to be in the lower part of the cell. Right now I have the cell alignment "bottom"

  • Insert a Comment into every Page MS word 2014-09-30

    Hi, I would like to know if theres any way to do a MS Word Macro that would allow me to insert a comment bubble with the same comment in every page of my document. Prefably in the middle of the end of every page. I found out how to search for a word

  • Formula needed: look for key words "1", "2" into a cell and for each one write "x", "y" 2014-10-09

    Hi, I am using Excel 2007, and I need to find a formula that looks for key words into a cell, and writes something if it finds it. I have a very long column of rough data, that cannot be ordered so I need to find a way to translate them into a standa

Copyright (C) pcaskme.com, All Rights Reserved.

processed in 0.495 (s). 13 q(s)