1 / 11

用 VBA 实现 PPT 中的交互功能

用 VBA 实现 PPT 中的交互功能. 主讲人:闫丽娟. 一、显示控件工具箱. 在 PowerPoint 中选择菜单“视图 / 工具栏 / 控件工具箱”. 二、控件工具箱中常用按钮的介绍. ( 1 )复选框( CheckBox ):可以选择多个选项,常用来设计多选题; ( 2 )文本框( TextBox ):可以输入文本,常用来设计填空题; ( 3 )命令按钮( CommandButton ):用来确定选择或输入,也可设计超级链接; ( 4 )单选框( OptionButton ):只能选中一个选项,常用来设计单选题或判断题;. 三、实例讲解:.

ianna
Download Presentation

用 VBA 实现 PPT 中的交互功能

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 用VBA实现PPT中的交互功能 主讲人:闫丽娟

  2. 一、显示控件工具箱 • 在PowerPoint中选择菜单“视图/工具栏/控件工具箱”

  3. 二、控件工具箱中常用按钮的介绍 • (1)复选框(CheckBox):可以选择多个选项,常用来设计多选题; • (2)文本框(TextBox):可以输入文本,常用来设计填空题; • (3)命令按钮(CommandButton):用来确定选择或输入,也可设计超级链接; • (4)单选框(OptionButton):只能选中一个选项,常用来设计单选题或判断题;

  4. 三、实例讲解: 1、利用单选框(OptionButton)做单项选择题 • 在PPT中输入题干: • 用单选框(OptionButton)控件制作选项 • (OptionButton)控件属性设置: • AutoSize:有两个值,True表示根据字的多少调整复选框的大小,False表示单选框为固定大小; • BackColor:设置单选框的背景颜色; • BackStyle:右侧的下拉列表中选择“0-fmBackStyleTransparent”,可以使做出的单选项背景透明。

  5. 属性设置 Caption:设置控件在幻灯片中对应显示的文本(即我们所需要的内容),把默认值删除再重新输入新名; Font:设置字体、字号及字形; Forecolor:设置字的颜色,设置方法同BackColor; Height:单选框的高度,直接输入数字即可; Width:单选框的宽度,直接输入数字即可;(一般高度和宽度自己拖曳鼠标来定) Value:单选框的值,True为选中,False则相反。

  6. 交互性对话框的设置 • 选中代表正确答案的那个单选项“A 8 ”,点击右键,在弹出菜单中选择“查看代码”命令,在打开的窗口中找到 Private Sub OptionButton1_Click() End Sub

  7. 交互性对话框的设置 在这两段代码中间插入代码: MsgBox ("恭喜您,答对了!") *设置提示框及提示信息的* msgbox是一个在VB里弹出一个对话框的函数

  8. 在 MsgBox (“恭喜您,答对了!”) 后面再加入新代码 OptionButton1.Value = False And OptionButton3.Value = False And OptionButton4.Value = False *单击A选项后使其它各选项恢复到未选中状态*

  9. 2、利用复选框(CheckBox)做多项选择题 用前面的方法插入四个复选框,调整好位置。 再插入一个命令按钮,打开“属性”对话框,将命令按钮的属性“Caption”值设为“提交答案”。 选中“提交答案”按钮,在右键菜单中选择“查看代码”命令,打开代码编辑窗口。

  10. 判断:如果第1、2个复选框均为选中状态的话,就弹出一个表示答对的提示框,否则就弹出一个答错的提示框判断:如果第1、2个复选框均为选中状态的话,就弹出一个表示答对的提示框,否则就弹出一个答错的提示框 在窗口中找到如下两句代码: Private Sub CommandButton1_Click() End Sub 在这两句代码中间插入以下代码: If CheckBox1.Value = True And CheckBox2.Value = True And CheckBox4.Value = FLASE And CheckBox3.Value = False Then MsgBox "厉害,答对了!", vbOKOnly, "多项选择题" Else MsgBox "不好意思,您做错了。再仔细想想?", vbOKOnly, "多项选择题" End If

  11. 如果将所有复选框的选中状态消除,以便再次选择,如何完成?如果将所有复选框的选中状态消除,以便再次选择,如何完成? 在 End If 前输入 CheckBox1.Value = False CheckBox2.Value = False CheckBox3.Value = False CheckBox4.Value = False

More Related