显示封面:
显示答题界面:
Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Public Const SND_ALIAS& = &H10000
Public Const SND_ASYNC& = &H1
Public Const SND_SYNC& = &H0
Public Const SND_NODEFAULT& = &H2
Public Const SND_FILENAME& = &H20000
Public Const SND_LOOP& = &H8
Public Const SND_PURGE& = &H40
Public Const sdDefault = ".Default"
Public Const sdClose = "Close"
Public Const sdEmptyRecycleBin = "EmptyRecycleBin"
Public Const sdMailBeep = "MailBeep"
Public Const sdMaximize = "Maximize"
Public Const sdMenuCommand = "MenuCommand"
Public Const sdMenuPopUp = "MenuPopup"
Public Const sdMinimize = "Minimize"
Public Const sdOpen = "Open"
Public Const sdSystemExclaimation = "SystemExclaimation"
Public Const sdSystemExit = "SystemExit"
Public Const sdSystemHand = "SystemHand"
Public Const sdSystemQuestion = "SystemQuestion"
Public Const sdSystemStart = "SystemStart"
'问题最小编号
Public Const IQuestionMinID = 3
'问题最大编号
Public Const IQuestionMaxID = 1230
'目前的编号
Public IQuestionCurrentID As Integer
'试题集的编号
Public SQuestionCollectID As String
Dim xlApp As Excel.Application
Dim LTCount As Integer
Dim SRow As String
Dim STEMP As String
Public ExcelAppSound As Excel.Application
Public TimerID As Long
Public TimesCount As Integer
Public BeStart As Boolean
Sub 选择试题()
'新建一个Excel程序
Set xlApp = New Excel.Application
'定义当前题库的位置
xlFilePath$ = ActivePresentation.Path & "\员工基本知识读本题库之一(地质).xls"
'后台打开Excel
xlApp.Workbooks.Open xlFilePath, , False
'关闭打开的Excel
xlApp.Workbooks.Close
'清空xlApp
Set xlApp = Nothing
'准备定时器
Dim time As Integer
time = 20000 '每页时间为20秒
timerStop '清理定时器
'倒计时20秒
ActivePresentation.Slides(1).Shapes("Rectangle 16").TextFrame.TextRange.Text = "20"
'开始计时
TimerStart time
End Sub
Sub OnSlideShowPageChange(ByVal Wn As SlideShowWindow)
'利用Excel播放语音
'Set ExcelAppSound = New Excel.Application
End Sub
Sub 第一题()
IQuestionCurrentID = IQuestionMinID
'写回
ActivePresentation.Slides(1).Shapes("Rectangle 12").TextFrame.TextRange.Text = Str(IQuestionCurrentID)
选择试题
End Sub
Sub 最后一题()
IQuestionCurrentID = IQuestionMaxID
'写回
ActivePresentation.Slides(1).Shapes("Rectangle 12").TextFrame.TextRange.Text = Str(IQuestionCurrentID)
选择试题
End Sub
Sub 上一题()
'获取当前的问题编号
STEMP = ActivePresentation.Slides(1).Shapes("Rectangle 12").TextFrame.TextRange.Text
If STEMP = "" Then STEMP = "3"
IQuestionCurrentID = Val(STEMP)
'试题号减1
IQuestionCurrentID = IQuestionCurrentID - 1
If IQuestionCurrentID < IQuestionMinID Then IQuestionCurrentID = IQuestionMinID
'写回
ActivePresentation.Slides(1).Shapes("Rectangle 12").TextFrame.TextRange.Text = Str(IQuestionCurrentID)
选择试题
End Sub
Sub 下一题()
'获取当前的问题编号
STEMP = ActivePresentation.Slides(1).Shapes("Rectangle 12").TextFrame.TextRange.Text
If STEMP = "" Then STEMP = "3"
IQuestionCurrentID = Val(STEMP)
'试题号加1
IQuestionCurrentID = IQuestionCurrentID + 1
If IQuestionCurrentID > IQuestionMaxID Then IQuestionCurrentID = IQuestionMaxID
'写回
ActivePresentation.Slides(1).Shapes("Rectangle 12").TextFrame.TextRange.Text = Str(IQuestionCurrentID)
选择试题
End Sub
Sub 中间出结果()
'停止计时器
TimerID = KillTimer(0, TimerID)
BeStart = False
'停止播放声音
Call PlaySound(vbNullString, 0&, SND_NODEFAULT)
'显示答案
ActivePresentation.Slides(1).Shapes("Rectangle 10").TextFrame.TextRange.Text = ActivePresentation.Slides(1).Shapes("Rectangle 18").TextFrame.TextRange.Text
End Sub
Sub OnSlideShowTerminate()
'幻灯片结束事件处理
'Set ExcelAppSound = Nothing
'如果计时器仍然在运行,需要结束
TimerID = KillTimer(0, TimerID)
End Sub
Sub TimerStart(ByVal time As Integer)
TimesCount = time / 1000
TimerID = SetTimer(0, 0, 1000, AddressOf TimerProc)
BeStart = True
End Sub
Sub timerStop()
If BeStart = False Then
Exit Sub
End If
'停止计时
TimesCount = 0
TimerID = KillTimer(0, TimerID)
BeStart = False
End Sub
Sub TimerProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal idEvent As Long, ByVal dwTime As Long)
'显示时间秒数
TimesCount = TimesCount - 1
ActivePresentation.Slides(1).Shapes("Rectangle 16").TextFrame.TextRange.Text = TimesCount
'最后1秒显示答案
If TimesCount = 1 Then
ActivePresentation.Slides(1).Shapes("Rectangle 10").TextFrame.TextRange.Text = ActivePresentation.Slides(1).Shapes("Rectangle 18").TextFrame.TextRange.Text
End If
'倒数5秒的处理
If TimesCount <= 5 Then
'停止声音
Call PlaySound(vbNullString, 0&, SND_NODEFAULT)
'如果需要可以播放语音念数字5、4、3、2、1
'ExcelAppSound.Speech.Speak Str(TimesCount)
'播放最后倒计时声音
Call PlaySound(ActivePresentation.Path & "\提醒.wav", 0&, SND_ASYNC Or SND_NODEFAULT)
'停止计时器
If (TimesCount <= 0) Then
Call PlaySound(ActivePresentation.Path & "\时间到.wav", 0&, SND_ASYNC Or SND_NODEFAULT) '如果时间长可以加SND_LOOP避免反复调用
TimerID = KillTimer(0, TimerID)
End If
Else
Call PlaySound(ActivePresentation.Path & "\计时.wav", 0&, SND_ASYNC Or SND_NODEFAULT)
End If
If Not BeStart Then
TimerID = KillTimer(0, TimerID)
End If
End Sub
Sub 选择试题集()
Load UserForm1
UserForm1.Show
ActivePresentation.Slides(1).Shapes("Rectangle 19").TextFrame.TextRange.Text = SQuestionCollectID
End Sub
Sub 隐藏和显示封面()
ActivePresentation.Slides(1).Shapes("Rectangle 20").Visible = Not ActivePresentation.Slides(1).Shapes("Rectangle 20").Visible
End Sub