locked
How to Create two Tables in MS-Word Document using .NET RRS feed

  • Question

  • User-873373993 posted

    How to Create two Tables in MS-Word Document using .NET.

    I have created one table. but i can't able to create second table.

    If i use this second time for 2nd table. 2nd table get created in 1st table's first Cell..

    Pls pls help me to create two table in Word documnet

    this is for 1st table.

    object fileName = HttpContext.Current.Request.MapPath("Example.doc");

    object readOnly = false;

    object isVisible = true;

    object missing = System.Reflection.Missing.Value;

    Word.Document oWordDoc;

    object start = 1;

    object end = 0;

    Word.Table newTable;

    Word.Range tableLocation = oWordDoc.Range(ref start, ref end);oWordDoc.Tables.Add(tableLocation, row, column, ref missing, ref missing);

    newTable = oWordDoc.Tables[1];

    for(int row=0; row<2; row++)

    {

    Word.Row newRow = oWordDoc.Tables[1].Rows.Add(ref missing);

    object count = 1;

    int i = 0;

    for (int Column = 1; Column <= 2; k++)

    {

    newRow.Cells[k].Range.Text = table.Rows[row].Cells[i].ToString();

    i = i + 1;

    oWordApp.Selection.MoveDown(ref missing, ref count, ref missing);

    }

    }

    Saturday, November 29, 2008 5:31 AM

Answers

All replies

  • User-1136466523 posted

    Hi,

    <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>

    You need to create another Word.Document objects, and then add new Table into Tables collection according to your way.

    <o:p> </o:p>

    Thanks.

     

    Wednesday, December 3, 2008 12:35 AM
  • User2077524089 posted

    Hi,

    http://support.microsoft.com/kb/316384

    Use this link it will be clarified ur  Doubt

    Wednesday, December 3, 2008 2:30 AM
  • User-873373993 posted

    Hai.. Thanks. i got answer.  this site helped me lot.

    http://support.microsoft.com/kb/316384

    Once again thanking you guys...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 3, 2008 5:27 AM