content control vsto RRS feed

  • Question

  • Hi All,

    When pasting table in a contentcontrol range, the table is not starting from the top. It is starting for center.


    ref i).Range.Select();


    Globals.ThisAddIn.Application.ActiveDocument.Application.Selection.PasteSpecial(ref missingVal, ref missingVal,ref missingVal, ref missingVal, ref typeHtml, ref missingVal, ref missingVal);

    I want the table to start vertically top.

    Is there anyway we can define the vertical position of the table inside content control.



    Monday, December 5, 2011 10:13 AM


  • Hi Sana

    The table isn't truly centered. What's happening is that there's an empty paragraph mark above and below the table. (Click the "backwards P" button in the Home tab, Paragraph group to turn on display of non-printing characters and you'll see them.)

    The paragraph mark following the table cannot be deleted - this is storing important information about the table structures.

    the paragraph mark preceding the table is appearing because, at the moment you insert additional paragraphs into a content control the paragraph mark that was immediately to the right of the content control is incorporated into the content control.

    This paragraph mark can be deleted. You might test whether something like the following works:

      Word.ContentControl cc = contentControls.get_Item(ref i);
      cc.Range.Paragraphs[1].Range.Delete(ref missing, ref missing);


    Cindy Meister, VSTO/Word MVP
    Monday, December 5, 2011 11:24 AM