VBA——批量設(shè)置PPT單元格數(shù)字格式

Rem 本視頻完整代碼
Sub 表格負(fù)數(shù)格式()
??'注意:會(huì)設(shè)置當(dāng)前演示文稿中每頁幻燈片的每個(gè)表格
??Dim sld As PowerPoint.Slide
??Dim tb As Table
??Dim sp As Shape
??Dim i As Long
??Dim j As Long
??Dim cel As Cell
??Dim s As String
???
??For Each sld In ActivePresentation.Slides
????For Each sp In sld.Shapes
??????If sp.HasTable Then
????????Set tb = sp.Table
?????????
????????For i = 1 To tb.Rows.Count
??????????For j = 1 To tb.Columns.Count
????????????Set cel = tb.Cell(i, j)
?????????????
????????????s = cel.Shape.TextFrame.TextRange.Text
?????????????
????????????'Debug.Print s
?????????????
????????????s = Trim(s)
????????????If Right(s, 1) = "%" Then
??????????????s = Mid(s, 1, Len(s) - 1)
????????????End If
?????????????
????????????If IsNumeric(s) Then
??????????????If Val(s) < 0 Then
????????????????cel.Shape.TextFrame.TextRange.Font.Color.RGB = RGB(255, 0, 0)
??????????????End If
????????????End If
??????????Next j
????????Next i
??????End If
????Next sp
??Next sld
??Set tb = Nothing
??Set cel = Nothing
End Sub
VBA——批量設(shè)置PPT單元格數(shù)字格式的評論 (共 條)
