如何在PPT中利用VBA程序设置某页上的表格文本框边距,并去除某个单元格中的特定文本

第二页ppt上只有这一个表格,最上头的蓝色边框部分是表格的第一行;由于涉及到的ppt文件很多,需要写一个vba程序来自动运行,谢过高手,问题解决了必定高分悬赏!
加急~!

以下代码演示了如何通过 PowerPoint VBA 替换第一个幻灯片中的指定单元格(这里固定第二行第一列)中的所有 “Overall”:

Sub 替换Overall()
    Dim tb As Table
    Dim sld As Slide
    Dim shp As Shape
    Dim txtRange As TextRange
    
    Const FIND_WHAT As String = "Overall"
    
    Set sld = ActivePresentation.Slides(1)
    Set shp = sld.Shapes(1)
    
    ' /* 第一个幻灯片的第一个形状中含有表格. */
    If shp.HasTable Then
        Set tb = shp.Table
        Set shp = tb.Cell(2, 1).Shape
        Set txtRange = shp.TextFrame.TextRange
        Set txtRange = txtRange.Replace(FIND_WHAT, _
                                        vbNullString, _
                                        WholeWords:=msoTrue)
        
        ' /* 循环替换所有的 Overall 为空. */
        Do While Not txtRange Is Nothing
            Set txtRange = shp.TextFrame.TextRange
            Set txtRange = txtRange.Replace(FIND_WHAT, _
                                            vbNullString, _
                                            WholeWords:=msoTrue)
        Loop
    End If
    
    Set tb = Nothing
    Set sld = Nothing
    Set txtRange = Nothing
End Sub


运行效果:


上面只是提供了最最核心的演示代码,并不能用作你的实际需求,如果要替换多个演示稿文件中的多个幻灯片,那么就需要套两层循环去做,希望你可以通过这个来举一反三!

温馨提示:答案为网友推荐,仅供参考
第1个回答  2014-12-25
这个实在难倒我了
相似回答