Vba 用于更改所有幻灯片中文本表颜色的代码
我想要一个宏,它可以循环浏览所有幻灯片,并将表格中的文本更改为黑色。当我尝试下面的代码时,我得到错误消息:Vba 用于更改所有幻灯片中文本表颜色的代码,vba,colors,powerpoint,Vba,Colors,Powerpoint,我想要一个宏,它可以循环浏览所有幻灯片,并将表格中的文本更改为黑色。当我尝试下面的代码时,我得到错误消息:方法'Table'的'Shape'失败 这是我的代码: Sub TableAllBlack() Dim lRaw As Integer Dim lCol As Integer Dim oTbl As Table Dim osld As Slide Dim oShp As Shape With ActivePresentation For Each oSl In .Slides
方法'Table'的'Shape'失败
这是我的代码:
Sub TableAllBlack()
Dim lRaw As Integer
Dim lCol As Integer
Dim oTbl As Table
Dim osld As Slide
Dim oShp As Shape
With ActivePresentation
For Each oSl In .Slides
For Each oSh In oSl.Shapes
Set oTbl = oSh.Table
With oTbl
For lRow = 1 To .Rows.Count
For lCol = 1 To .Columns.Count
With .Cell(lRow, lCol).Shape
If .HasTextFrame Then
If .TextFrame.HasText Then
TextFrame.TextRange.Font.Color.RGB = RGB(0, 0, 0)
End If
End If
End With
Next
Next
End With
Next
Next
End With
End Sub
并非每个形状都有与其关联的表。只要添加语句
如果oSh.HasTable那么…
就可以了
此
If
语句应放在封装所有表调用的位置,因此请将其直接放在Set oTbl=oSh.Table
行之前谢谢您的回答!我仍然有一个错误:TextFrame.TextRange.Font.Color.RGB=RGB(0,0,0)。它总是来的对象要求!我该怎么办?Thanks@Zigouma在TextFrame之前添加句点