none
How do I get the Widths and Heights of table in PowerPoint? RRS feed

  • Question

  • A simple question, but not such a simple answer I bet.

    If I dynamically render a table with many rows how can I find out the height of each row and the overall height of the the table?  I can do this in VBA without issue as I can get the height of a row after I have added it, but cannot get the correct height using the SDK.  I guess it is down to VBA actually rendering and reporting on the rendered row, whereas the SDK isn't actually able to render and can't report on the final dimensions.  Any hints or pointers in how I can make a "best guess" on the height would be very helpful.

    Need to use the SDK as I'm putting a server based solution together not a desktop one.

    Thanks,
    Steve

    Tuesday, April 26, 2011 5:15 PM

Answers

  • Hi Steve,

    Sorry for the late reply.

    After reading your post carefully, I did some research about your problem.

    I create a powerpoint file and look into it via open xml productivity tool. I found we can get the width and height of table under the slide1.xml file. Below is the table information in the file:'

    <a:tbl xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
      <a:tblPr firstRow="1" bandRow="1">
        <a:tableStyleId>{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}</a:tableStyleId>
      </a:tblPr>
      <a:tblGrid>
        <a:gridCol w="2032000" />
        <a:gridCol w="2032000" />
        <a:gridCol w="2032000" />
      </a:tblGrid>
      <a:tr h="370840">
        <a:tc>
          <a:txBody>
            <a:bodyPr />
            <a:lstStyle />
            <a:p>
              <a:r>
                <a:rPr lang="en-US" dirty="0" smtClean="0" />
                <a:t>4442453a</a:t>
              </a:r>
              <a:endParaRPr lang="en-US" dirty="0" />
            </a:p>
          </a:txBody>
          <a:tcPr />
        </a:tc>
        <a:tc>
          <a:txBody>
            <a:bodyPr />
            <a:lstStyle />
            <a:p>
              <a:endParaRPr lang="en-US" />
            </a:p>
          </a:txBody>
          <a:tcPr />
        </a:tc>
        <a:tc>
          <a:txBody>
            <a:bodyPr />
            <a:lstStyle />
            <a:p>
              <a:endParaRPr lang="en-US" />
            </a:p>
          </a:txBody>
          <a:tcPr />
        </a:tc>
      </a:tr>
      <a:tr h="370840">
        <a:tc>
          <a:txBody>
            <a:bodyPr />
            <a:lstStyle />
            <a:p>
              <a:endParaRPr lang="en-US" />
            </a:p>
          </a:txBody>
          <a:tcPr />
        </a:tc>
        <a:tc>
          <a:txBody>
            <a:bodyPr />
            <a:lstStyle />
            <a:p>
              <a:endParaRPr lang="en-US" />
            </a:p>
          </a:txBody>
          <a:tcPr />
        </a:tc>
        <a:tc>
          <a:txBody>
            <a:bodyPr />
            <a:lstStyle />
            <a:p>
              <a:endParaRPr lang="en-US" dirty="0" />
            </a:p>
          </a:txBody>
          <a:tcPr />
        </a:tc>
      </a:tr>
    </a:tbl>

    We can see that the mark language contains the information about each row's height and each column's width. So we just get all the elements and the attributes' value and sum together. Then, we will get the table's width and height.

    The w="2032000" is measured as EMU, if you want to convert to other units, you can refer to this article:

    http://startbigthinksmall.wordpress.com/2010/01/04/points-inches-and-emus-measuring-units-in-office-open-xml/

    Hope this can help you and just feel free to follow up.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Bruce Song Tuesday, May 10, 2011 12:53 PM
    Tuesday, May 3, 2011 8:32 AM