簡體   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