【发布时间】:2018-01-30 14:28:44
【问题描述】:
我想在 powerpoint 中创建一个宏,当我单击按钮时将数字增加 1,我有以下宏可以在几秒钟的延迟之间增加计数器,但我想在单击时增加计数器,如何我可以改变它吗?
Private Sub CommandButton1_Click()
Offset = ActivePresentation.PageSetup.SlideHeight + 10
CountNo = 1
' ADJUST THIS waitTime NUMBER WITH SECONDS DELAY BETWEEN COUNTER INCREMENTS
waitTime = 0.5
' ADJUST THIS maxCount NUMBER WITH MAXIMUM NUMBER COUNTER SHOULD REACH
maxCount = 5000
Do Until CountNo = maxCount + 1
ActivePresentation.SlideMaster.Shapes("Counter").TextFrame.TextRange.Text = CountNo
ActivePresentation.SlideMaster.Shapes("Counter").Top = ActivePresentation.SlideMaster.Shapes("Counter").Top + Offset
DoEvents
ActivePresentation.SlideMaster.Shapes("Counter").Top = ActivePresentation.SlideMaster.Shapes("Counter").Top - Offset
x = Timer
While Timer - x < waitTime
DoEvents
Wend
CountNo = CountNo + 1
If SlideShowWindows.Count = 0 Then
ActivePresentation.SlideMaster.Shapes("Counter").TextFrame.TextRange.Text = 1
ActivePresentation.SlideMaster.Shapes("Counter").Top = ActivePresentation.SlideMaster.Shapes("Counter").Top + Offset
DoEvents
ActivePresentation.SlideMaster.Shapes("Counter").Top = ActivePresentation.SlideMaster.Shapes("Counter").Top - Offset
Exit Do
End If
Loop
End Sub
【问题讨论】:
标签: vba counter increment powerpoint