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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14506324/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 19:20:31  来源:igfitidea点击:

How to refresh the active Slide in a slide show?

vbapowerpointpowerpoint-vba

提问by Christopher

Based on my last questionI got the right code to change the image of an shape.
Unfortunatly, this does not update the active Presentation. If I close the presentation and restart it, the image is changed, but the change should be directly visible.

根据我的最后一个问题,我得到了正确的代码来更改形状的图像。
不幸的是,这不会更新活动的演示文稿。如果我关闭演示文稿并重新启动它,图像会更改,但更改应该直接可见。

This is my code to change the image:

这是我更改图像的代码:

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

I found a way to update the presentation, but this lets the presentation flicker.

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

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

Edit
I tried refreshing the slide as proposed here, but this didn't worked for me.

编辑
我尝试按照此处的建议刷新幻灯片,但这对我不起作用。

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

Edit 2
I uploaded my file: Download

编辑 2
我上传了我的文件:下载

回答by Christopher

In the end I found my answer in this blog post. It appears to be a bug in PowerPoint 2007.

最后我在这篇博文中找到了答案。这似乎是 PowerPoint 2007 中的一个错误。

This code helps to fix the bug:

此代码有助于修复错误:

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

回答by Peerapat Sirichot

I found this bug in my Power Point as well, I add this line into the code and it fixes the bug

我也在我的 Power Point 中发现了这个错误,我将此行添加到代码中并修复了该错误

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

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