Search code examples
vbapowerpoint

How to refresh the active Slide in a slide show?


Based on my last question I 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


Solution

  • In the end I found my answer in this blog post. It appears to be a bug in 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