繁体   English   中英

以编程方式在Powerpoint演示文稿中编辑Text,Tables和Tablesproperties

[英]Programatically edit Text, Tables and Tablesproperties in a Powerpoint presentation

我必须编写一个程序,该程序从SharePoint中读取一些数据并将其写入PowerPoint演示文稿中。 演示文稿中有一些通配符,例如## budget ##,我必须将其替换为SharePoint中的值。 我认为,这可以通过搜索并替换为PowerPoint演示文稿来完成。

但是也有一些表格,背景必须用红色,绿色,黄色等颜色填充,我不知道,有哪些选项可以识别特定的表格和受影响的单元格,而哪种方法是最好的方法。

这将适用于一个通配符; 您需要将其更改为采用一个参数(您要搜索的不同通配符文本字符串),或调用另一个例程依次搜索每个通配符。 但是,这是在单元格中查找文本并根据需要为其着色的方式:

Dim oSl As Slide
Dim oSh As Shape
Dim oTbl As Table
Dim x As Long
Dim y As Long

For Each oSl In ActivePresentation.Slides
    For Each oSh In oSl.Shapes

        ' other code here to check for ## text in the shape

        If oSh.HasTable Then
            Set oTbl = oSh.Table
            With oTbl
                For x = 1 To .Rows.Count
                    For y = 1 To .Columns.Count
                        With .Cell(x, y)
                            If InStr(.Shape.TextFrame.TextRange.Text, "##budget##") > 0 Then
                                .Shape.Fill.ForeColor.RGB = RGB(255, 0, 0)
                            End If
                        End With
                    Next
                Next
            End With

        End If
    Next
Next

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM