-1

大约有 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
4

1 回答 1

0

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

另一个更深层次的问题是,您可能希望在模块顶部声明 start_time,因为一旦 start_time 子退出,它就会消失(即不再可用):在模块顶部键入 dim 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
于 2013-05-19T14:54:40.467 回答