chetan Allipur

chetan Allipur

  • NA
  • 541
  • 166.4k

How to split the rows in Table if it is vertically merged.

Sep 12 2017 5:17 AM
How to split the rows in Table if it is vertically merged cells.
 
I am getting error like this "Cannot access individual rows in this collection because the table has vertically merged cells. word"
 
here is my code
 
Range rHeaderRows = default(Range);
int i = 0;
if (cbxRepeate.Checked == true)
{
nRowHeaders = wordsec.Range.Rows.First.Index - 1;
if (nRowHeaders >= Numdropdown.Value)
{
if (wordsec.Range.Rows.First.Index > nRowHeaders)
{
rHeaderRows = wordsec.Tables[1].Rows[1].Range;
rHeaderRows.End = wordsec.Tables[1].Rows[(int)Numdropdown.Value].Range.End;
}
wordsec.SplitTable();
wordsec.TypeText("\n");
wordsec.MoveRight(WdUnits.wdCharacter, 1);
if (nRowHeaders > 0)
{
rHeaderRows.Copy();
wordsec.Paste();
//for (i = 1; i <= nRowHeaders; i++)
//{
// wordsec.Tables[1].Rows[i].HeadingFormat = -1;
//}
}
wordsec.Tables[1].Select();
wordsec.MoveLeft(WdUnits.wdCharacter, 2);
wordsec.Font.Bold = 1;
wordsec.Fields.Add(wordsec.Range, WdFieldType.wdFieldEmpty, "STYLEREF Table", true);
wordsec.TypeText(" " + "(continued)");
wordsec.Paragraphs.set_Style("TableCont");
}
else
{
MessageBox.Show("You have selected invalid row", "ARID - Split Table", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
 
Please tell me how to resolve this issue. 

Answers (1)