PPT幻灯片用的人应该不少吧……
前些日子朋友做了个幻灯片,说想在演讲时和台下的人互动——小问答,需要计时……
怎么办呢?于是想起了VBA……
在 “工具”/“自定义” 里,找到 “工具拦” 选项卡,找到“控件和工具箱”,将前面打钩。
在一张幻灯片上拖个 按钮 和 文本框。
双击 按钮,打开代码窗口
输入:
Private Sub CommandButton1_Click()win_hwnd = GetActiveWindow()TextBox1.Text = "10"SetTimer win_hwnd, 101, 1000, AddressOf timer
End SubPrivate Sub TextBox1_Change()If TextBox1.Text <= 0 ThenKillTimer win_hwnd, 101MsgBox "Time Up!", vbInformation, "T_T"End If
End Sub
再在里面添加一个模块,输入:
Public Declare Function GetActiveWindow Lib "user32" () As LongPublic Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, _ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As LongPublic Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, _ByVal nIDEvent As Long) As LongPublic win_hwnd As LongPublic Sub timer()Slide1.TextBox1.Text = Val(Slide1.TextBox1.Text) - 1
End Sub
关闭代码窗口
开始放映幻灯片,点 按钮,好了开始计时了
用这个例子小赞下VBA
其实里面还能创建窗体……
恩,PPT也玩RIA,-_-/
J.Y. Liu
2010.01.18