Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have a VBA loop that cycles through the selected cells of a PowerPoint table to update the formatting. The following lines work great:

        With objTable.Rows(the_row).Cells(the_col).Shape.TextFrame.TextRange.Font
            .Size = 12
            .Color = RGB(0, 0, 102)
        End With
        With objTable.Rows(the_row).Cells(the_col).Shape.TextFrame
            .VerticalAnchor = msoAnchorMiddle
        End With

I'm having trouble finding the syntax to modify the number format (to change the number of decimals, add a comma, etc.) and to change the internal margin of the cell (which I can do manually with a right click -> Format Shape -> Text Box -> Internal Margin). Usually I use the record macro option to get to that detailed syntax, but I'm not seeing that option in PowerPoint.

share|improve this question
2  
There is no longer a Record Macro option in PPT, unfortunately. You'll also discover (as I did) that there are far fewer resources available to the aspiring VBA developer who wants to work in PPT. MSDN documentation, and StackOverflow will be your best friend :) – David Zemens May 22 at 16:34

1 Answer

up vote 2 down vote accepted
With objTable.Rows(the_row).Cells(the_col).Shape.TextFrame

'Internal margin:
        .MarginLeft = 'value goes here
        .MarginRight = 'value goes here
        .MarginTop = 'value goes here
        .MarginBottom= 'value goes here


'number Format:

    .TextRange.text = Format(1000, "#,##0.00") 'replace 1000 with your value

end with
share|improve this answer
I had tried this and it didn't work, but it just hit me that the value probably has to be in pixels and not inches...is that right? And for the number format, the number is already there, so would this work: .TextRange.Text = Format(.TextRange.Text, "#,##0.00")? Thanks! – rryanp May 23 at 13:14
I just tested both of those things, and they both work (use pixels and send the text range value as a parameter of the Format function). Thanks a lot for your help! – rryanp May 23 at 13:19
Values are POINTS, not pixels – Steve Rindsberg May 26 at 14:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.