关键字Privateshe用于声明模块/窗体级别的变量,而Dim适用于模块中的局部变量的声明
(以改变图形颜色的代码段作为测试手段)
(1)关键字Dim声明局部变量:
Sub Dim声明局部变量()
Dim sld As Slide, shp As Shape
For Each sld In ActivePresentation.Slides
For Each shp In sld.Shapes
shp.Fill.ForeColor.RGB = vbRed
Next
Next
End Sub
运行结果:
(2)关键字Private声明模块级别的私有变量:
Private sld As Slide
Sub Pri