Programatically write after a table in word using C# RRS feed

  • Question

  • Hi,

    I am writing a console application , in which i am creating a table in Word document, which will write into the table but some of the text i want to write outside the table, but what ever i write it writes inside the table only...

    anyone please help.

    Thanks, Parth

    • Moved by Cindy Meister MVPModerator Tuesday, August 28, 2012 11:07 AM Word-specific and not using VSTO technology (From:Visual Studio Tools for Office)
    Tuesday, August 28, 2012 11:01 AM


  • Hi Parth

    I've moved this to the Word for Developers forum since you're not working with the VSTO technology.

    It's difficult to give you a definitive answer based on the little information you give us. I'm guessing that you're using the Selection object, rather than the Range object in your code - it would help if you'd include a code sample and tell us the version of Word involved.

    You may find the following article helpful for the basic coding involved with generating tables in Word.

    In general terms, in order to move "beyond" a table and work after the table, you need something similar to this (written from memory, so there may be syntax errors):

      Word.Range rng = theTable.Range;
      object oCollapseEnd = Word.WdCollapseDirection.wdCollapseEnd;
      rng.Collapse(ref oCollapseEnd);
      rng.Text = "Text to follow the table...";

    Cindy Meister, VSTO/Word MVP

    • Marked as answer by Parth Rawal Tuesday, August 28, 2012 11:38 AM
    Tuesday, August 28, 2012 11:13 AM