在第二张幻灯片上无法使用宏的情况下通过 powerpoint 进行 [英] progress through powerpoint with macros not working on second slide

查看:34
本文介绍了在第二张幻灯片上无法使用宏的情况下通过 powerpoint 进行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个宏,它将在 PowerPoint 演示文稿中的幻灯片中运行.我让它工作,但现在它停止工作,我不知道为什么.

I'm trying to create a macro which will run through slides in a powerpoint presentation. I had it working, but now it has stopped working and I don't know why.

运行幻灯片和动画的 vbscript 是

The vbscript to run through the slides and animation are

Private Sub PPTEvent_SlideShowNextBuild(ByVal Wn As SlideShowWindow)
    Sleep 1000
    SendKeys "{RIGHT}"
End Sub


Private Sub PPTEvent_SlideShowNextSlide(ByVal Wn As SlideShowWindow)
    Sleep 1000   
    SendKeys "{RIGHT}"
End Sub

有没有更好的方法来实现这一点?我看不出问题出在哪里,我也试过删除 Sleep 1000,但没有骰子.

Is there a better way to accomplish this? I can't see where the problem is, I've tried removing Sleep 1000 as well, but no dice.

奇怪的是,如果我同时使用两个

Strangely, if I use both

SendKeys "{ENTER}"
SendKeys "{RIGHT}"

一起,正如我所希望的那样,它贯穿了整个幻灯片.

together, it runs through the entire slideshow as I'd hoped.

推荐答案

这里是另一种基于 幻灯片设置

MSDN 页面中有一个错误,我已经在下面更正了(需要对 LoopUntilStopped 使用 msoTrue/False 而不是 True/False).

There is an error in the MSDN page which I have corrected below (need to use msoTrue/False not True/False for LoopUntilStopped).

当您进入幻灯片模式并且动画运行正常时,它会自动启动.

It starts automatically when you enter SlideShow mode and the animations run OK.

在标准模块中...

Public showRunning As Boolean

Sub runSlides()

  showRunning = True
  For Each s In ActivePresentation.Slides
    With s.SlideShowTransition
      .AdvanceOnTime = msoTrue
      .AdvanceTime = 1
    End With
  Next

  With ActivePresentation.SlideShowSettings

    .RangeType = ppShowAll
    .AdvanceMode = ppSlideShowUseSlideTimings
    .LoopUntilStopped = msoFalse
    .ShowWithAnimation = msoTrue
    .Run

  End With

End Sub

Public Sub OnSlideShowPageChange(ByVal Wn As SlideShowWindow)

  If Not showRunning Then
    runSlides
  End If

End Sub

Public Sub OnSlideShowTerminate(ByVal Wn As SlideShowWindow)
  showRunning = False
  closeSlideShow
End Sub

Public Sub closeSlideShow()
Dim s As Slide

  For Each s In ActivePresentation.Slides
    With s.SlideShowTransition
      .AdvanceOnTime = msoFalse
    End With
  Next

  On Error Resume Next
  ActivePresentation.SlideShowWindow.View.Exit
  On Error GoTo 0

End Sub

添加了 closeSlideShow 例程以停止每次运行幻灯片.

Added the closeSlideShow routine to stop slideshow running every time.

注意:以编程方式或手动取消选中幻灯片放映"功能区选项卡中的使用计时"将 .AdvanceOnTime 设置为 msoFalse,将停止幻灯片放映.似乎将其设置为 msoTrue,将其设置为 msoFalse,并尝试在同一例程中执行 ActivePresentation.SlideShowSettings.Run 将不起作用!

Note: setting .AdvanceOnTime to msoFalse programatically or manually un-checking Use Timings in the SLIDE SHOW ribbon tab, will stop the slideshow from running. It seems that setting this to msoTrue, having entered with it set to msoFalse, and trying to do ActivePresentation.SlideShowSettings.Run in the same routine will not work!

这篇关于在第二张幻灯片上无法使用宏的情况下通过 powerpoint 进行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆