阅读演示文稿所需的时间

时间:2013-05-19 14:42:59

标签: vba powerpoint

大约有500张幻灯片,第一张幻灯片是介绍,第二张幻灯片用于指示Start_time宏的操作按钮 - 一旦点击计时器启动。幻灯片3 - 499每个都有一个单词,因此读者必须在一段时间内浏览每张幻灯片,这就是为什么word_count等于slide.count减去三。最后一张幻灯片将显示操作按钮,单击该按钮将显示阅读评估。

此宏用于我的PowerPoint演示文稿,旨在为我的学生提供阅读评估。

Dim Start_time As Date
_______________________________________________________________________________________
Sub Start_time()
'at action button click in the first slide the time starts counting
Start_time = Now()

End Sub
_______________________________________________________________________________________

Sub ReadingTime()
'at action button click on the last slide the evaluaton message appears
Dim Reading_Time As String
Dim End_Time As Date
Dim iTotal_time As Long
Dim Word_count As Integer


End_Time = Now()
iTotal_time = DateDiff("d", End_Time, Start_time)
Word_count = ActivePresentation.Slides.Count - 3
Reading_Time = Word_count / iTotal_time * 24 * 60


MsgBox "Evaluation : Your reading speed is " & Reading_Time & "words per minute"

End Sub

1 个答案:

答案 0 :(得分:0)

你不是指end_time = now()吗?!!!

另一个更深层次的问题是你可能想要在模块顶部声明start_time,因为一旦start_time子退出,当范围(即不再可用)时它将会熄灭:type  昏暗的start_time 就在模块的顶部来做这件事。

试试这个:

Dim m_start_time As Date 'renamed this as it clashes with a function name

Public Sub Start_time()
    'at action button click in the first slide the time starts counting
    m_start_time = Now()

End Sub


Public Sub ReadingTime()
    'at action button click on the last slide the evaluaton message appears
    Dim Reading_Time As String
    Dim End_Time As Date
    Dim iTotal_time As Double   'use a double as fraction days are important
    Dim Word_count As Integer


    End_Time = Now()
    iTotal_time = End_Time - m_start_time
    Word_count = ActivePresentation.Slides.Count - 3
    Reading_Time = Word_count / iTotal_time * 24 * 60


    MsgBox "Evaluation : Your reading speed is " & Reading_Time & "words per minute"

End Sub