none
How do you change the height of a table cell or row in a Word table using Visual Studio 2010? RRS feed

  • Question

  • I would like to change the height of an individual cell (or row) in a Word table using Visual Basic.  This is the code I currently have, but it results in a syntax error:

    tbl.Cell(6,1).SetHeight() = 3.5

    Does anyone know the correct syntax to perform this task?

    Thanks in advance,

    Jim


    James Hutchinson

    Tuesday, January 5, 2016 3:45 PM

Answers

  • Hello,

    to modify the height of the cells we have 2 ways.

    (1) using height property

    (2) using SetHeight()

    we have to provide atleast 2 parameters. first one is height of the cell and second one is Height Rule.

    Height Rule contains the 3 values.

    Member   name

    Description

    wdRowHeightAuto

    The row height is adjusted to   accommodate the tallest value in the row.

    wdRowHeightAtLeast

    The row height is at least a   minimum specified value.

    wdRowHeightExactly

    The row height is an exact value.

    Below is a code sample that you can try.

    Me.Tables(1).Rows(1).Cells(1).SetHeight(15.0, Microsoft.Office.Interop.Word.WdRowHeightRule.wdRowHeightAtLeast)


    Regards

    Deepak

    • Marked as answer by jhutch03 Wednesday, January 6, 2016 6:34 AM
    Wednesday, January 6, 2016 5:29 AM
    Moderator

All replies

  • Hello,

    to modify the height of the cells we have 2 ways.

    (1) using height property

    (2) using SetHeight()

    we have to provide atleast 2 parameters. first one is height of the cell and second one is Height Rule.

    Height Rule contains the 3 values.

    Member   name

    Description

    wdRowHeightAuto

    The row height is adjusted to   accommodate the tallest value in the row.

    wdRowHeightAtLeast

    The row height is at least a   minimum specified value.

    wdRowHeightExactly

    The row height is an exact value.

    Below is a code sample that you can try.

    Me.Tables(1).Rows(1).Cells(1).SetHeight(15.0, Microsoft.Office.Interop.Word.WdRowHeightRule.wdRowHeightAtLeast)


    Regards

    Deepak

    • Marked as answer by jhutch03 Wednesday, January 6, 2016 6:34 AM
    Wednesday, January 6, 2016 5:29 AM
    Moderator
  • Deepak,

    This worked for me, except I had to replace "Me.Tables(1)" with the name of my table variable ("tbl").

    Thank you!


    James Hutchinson

    Wednesday, January 6, 2016 6:34 AM