PPT实现单页点名的方式
-
安装OK控件来实现,网上有很多资源,介绍很详细,不赘述。不爽的地方就是还要控件
-
通过PPT 开发工具中的控件来实现
1)office默认是没有把“开发工具”显示出来的。我们可以要把它先显示出来。依次点击 文件-> 选项->自定义功能区 中勾选 开发工具。如图:
2)选取开发工具中的命令按钮(CommandButton),添加到PPT页面中。如图:
3)双击CommandButton1,进入VBA界面下的控件回调函数Sub CommandButton1_Click()
4)在CommandButton1_Click内添加代码
Private Sub CommandButton1_Click()
Randomize
Dim a() As Variant
a = Array("1", "2", "3", "4", "5", "6", "7", "8")
Dim i As Integer
i = Int(8 * Rnd)
CommandButton1.Caption = a(i)
End Sub
5) 修改控件的属性,即,更新控件名字的字体、大小,美化控件。该步骤通过右键在“属性表”中更改。如图:
-
通过PPT 开发工具中的模块来实现
遗憾的是没有在mac系统中找到PPT的控件,被逼无奈通过该方式实现
1)在开发工具里边打开VBA界面,插入模块
2)在模块1中添加如下代码,其中OnSlideShowPageChange函数感兴趣的可以深入了解一下,这个是幻灯片放映页面切换时的回调函数
Sub OnSlideShowPageChange()
'最后插入需要更新的文本框
Dim LastShape As Integer
Dim SlideID As Integer '幻灯片页码
SlideID = 2
LastShape = ActivePresentation.Slides(SlideID).Shapes.Count
ActivePresentation.Slides(SlideID).Shapes(LastShape).Delete
Randomize
Dim a() As Variant
a = Array("1", "2", "3", "4", "5", "6", "7", "8")
Dim i As Integer
i = Int(8 * Rnd)
With ActivePresentation.Slides(SlideID)
With .Shapes.AddTextbox(msoTextOrientationHorizontal, 800, 350, 450, 100)
.TextFrame.TextRange.Font.Color = vbRed
.TextFrame.TextRange.Font.Size = 38
.TextFrame.TextRange.Text = a(i)
End With
End With
End Sub
3)在当前页PPT中增加一个超链接指向本页PPT。
注:制作PPT的时候,最后添加点名模块的文本框
以上!