如何刷新幻灯片中的活动幻灯片?

时间:2013-01-24 16:39:59

标签: vba powerpoint powerpoint-vba

基于my last question,我得到了正确的代码来更改形状的图像 不幸的是,这不会更新活动的演示文稿。如果我关闭演示文稿并重新启动它,图像会更改,但更改应该直接可见。

这是我更改图片的代码:

ActivePresentation.SlideShowWindow.View.Slide.Shapes("SolutionA_Image").Fill.UserPicture ("D:\User\SolutionWrong.jpg")

我找到了一种更新演示文稿的方法,但这会让演示文稿闪烁。

ActivePresentation.SlideShowWindow.Height = ActivePresentation.SlideShowWindow.Height - 1
ActivePresentation.SlideShowWindow.Height = ActivePresentation.SlideShowWindow.Height + 1

修改
我按照建议here尝试刷新幻灯片,但这对我没用。

Dim lSlideIndex As Long
lSlideIndex = SlideShowWindows(1).View.CurrentShowPosition
SlideShowWindows(1).View.GotoSlide lSlideIndex

编辑2
我上传了我的文件:Download

2 个答案:

答案 0 :(得分:2)

最后,我在this blog post找到了答案。它似乎是PowerPoint 2007中的一个错误。

此代码有助于修复错误:

Dim osld As Slide
'get current slide
Set osld = ActivePresentation.SlideShowWindow.View.Slide
'the next line adds the empty textbox and refreshs the slide
osld.Shapes.AddTextbox msoTextOrientationHorizontal, 1, 1, 1, 1

答案 1 :(得分:0)

我在Power Point中也发现了这个bug, 我将这一行添加到代码中,它修复了错误

Application.SlideShowWindows(1).View.GotoSlide Me.SlideIndex