使用VBA更改PowerPoint表格单元格的内部边距和/或数字格式

时间:2013-05-22 15:25:06

标签: vba powerpoint powerpoint-vba

我有一个VBA循环,循环访问PowerPoint表格的选定单元格以更新格式。以下几行很有用:

        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

我无法找到修改数字格式的语法(更改小数位数,添加逗号等)并更改单元格的内部边距(我可以通过右键单击手动完成) - >格式形状 - >文本框 - >内部保证金)。通常我使用记录宏选项来获得详细的语法,但我没有在PowerPoint中看到该选项。

1 个答案:

答案 0 :(得分:3)

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