0

I have a table in Word document. I want to able to select a row or column or only a cell or whole table to modify. now I can select the complete table and modify all cells, but I can not select a single row or column or cell. I can not create a range for this purpose. below my code for select whole of table:

if (WordAddIn.Config.ApplicationConfig.TemplateLanguage.ValueToShare == true)
                {
                    for (int i = 1; i <= WordManager.Selection.Tables[1].Rows.Count; i++)
                    {
                        for (int j = 1; j <= WordManager.Selection.Tables[1].Columns.Count; j++)
                        {
                           ...
                                }
                            }
                            else
                            { }
                        }
                    }

Thoughts?

2 Answers 2

1

Create a macro of what you need. Look at the VB calls of the macro and mimic/use those calls in your code.

0
0

You have to know the index of your table/row/column, but this is how you get the reference to each. From there, you can edit, delete, add, etc.

       Word.Table myTable = Globals.ThisDocument.Tables[0];
       //Get Row
       Word.Row myRow = myTable.Rows[0];
       //Get Column
       Word.Column myCOl = myTable.Columns[0];
       //Get Cell
       int rowNum = 0;
       int colNum = 0;
       Word.Cell myCell = myTable.Cell(rowNum, colNum);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.