我有一个带有嵌入式Word文档的PowerPoint演示文稿。我在演示文稿上有一个宏按钮,用于打开嵌入的Word文档,更改某些内容,并将它作为PDF文档保存(单词)。但是一旦完成,用户将显示幻灯片模式,而演示文稿(幻灯片)仍在后台运行。我如何将焦点带回到正在运行的幻灯片?该宏应该以幻灯片模式运行。PowerPoint VBA代码将焦点带回运行PowerPoint幻灯片
下面是我的代码
Private Sub Gen_Click()
' I am changing the presentation to normal view, in order to execute DoVerb thing!
ActivePresentation.Windows(1).Activate
With ActivePresentation.Slides(2).Shapes(1)
If .Type = msoEmbeddedOLEObject Then
For Each sVerb In .OLEFormat.ObjectVerbs
nCount = nCount + 1
If sVerb = "Open" Then
.OLEFormat.DoVerb nCount
Exit For
End If
Next
End If
End With
'switch back to slide show view
SlideShowWindows(1).Activate
'getting opened word document object to do stuff in in
Set objWord = GetObject(, "Word.Application")
Set objDoc = objWord.ActiveDocument
objWord.Visible = False
'Doing stuff here
'closing the word doc
objDoc.Saved = True
objWord.Quit
End Sub
该代码使得功率点返回到正常模式按钮恢复幻灯片!
您是否尝试过移动“SlideShowWindows(1).Activate”行到最后,就这样结束前分? – 2014-09-30 14:39:09
感谢您的评论!是的,我尝试过!如果我们使用F8来逐步执行,那么它工作得很好!但在实际幻灯片播放时失败!我也尝试使用SendKeys发送%TAB切换,%n最小化,但这些都不起作用! – 2014-09-30 23:33:18