Search code examples
vbapowerpoint

How to set a cells vertical alignment in a table in PowerPoint with VBA?


Using VBA in PowerPoint I am trying to set a cell (within a table) it's Vertical alignment property. In PowerPoint this property can be accessed via "Layout" (when focus is on the cell), click Cell Margins, click Custom Margins. You'll see Vertical Alignment there.

I have figured out how to change the internal margins:

With objTable.Rows(the_row).Cells(the_col).Shape.TextFrame.MarginLeft = ' value in points.

Thank you


Solution

  • You can access and change it this way:

    objTable.Rows(the_row).Cells(the_col).Shape.TextFrame.VerticalAnchor = msoAnchorMiddle
    

    https://learn.microsoft.com/en-us/office/vba/api/powerpoint.textframe.verticalanchor