none
Copy table content with C # RRS feed

  • Question

  • Hello everyone, 
    I'm trying to develop an Add-In for Microsoft Word (I am following these guides: http://msdn.microsoft.com/en-us/library/cc442946.aspx) and I would like to copy the contents of one table to another.

    For now I managed to do it in this way:

    table1.Cell(1, 0).Range.Text = table2.Cell(1, 0).Range.Text

    This only works with plain text but not with pictures or formatted texts.

    Could someone explain to me how I have to do to copy all the contents?

    Wednesday, October 22, 2014 3:50 PM

Answers

  • Hi,

    According to your description, you want to copy all the contents of a cell from one table to another.

    In fact, in the Range object, Word Object Model use Text property to represent the plain text, use InlineShape property to represent pictures and so on. So to achieve the goal, we just need to copy and paste the Range Object with Range.Copy/Paste Method. In this way, the plain text, pictures or formatted text will be copy totally.

    table2.Cell(1, 0).Range.Copy();
    table1.Cell(1, 0).Range.Paste();

     


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, October 23, 2014 7:17 AM
    Moderator