Share via

Refresh slide after master is changed programatically

Anonymous
2012-01-16T15:15:55+00:00

Hi,

If, while in the Normal view, I edit the text in a textbox (shape) on the SlideMaster with VBA, the change does not take effect on the screen until I go to another slide and back, or go to the master or notes views, and back to the normal view.

Is there a trick to get a slide to refresh after its slide master (that’s master, not layout) is modified by code?

I’m using this to change the textbox on the master slide:

    ActivePresentation.SlideMaster.Shapes("myShape").TextFrame.TextRange.Text = “New text”

Cheers

Rich

Microsoft 365 and Office | PowerPoint | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Steve Rindsberg 99,166 Reputation points MVP Volunteer Moderator
2012-01-16T17:02:46+00:00

Assuming you have a reference to the slide in oSld:

Activewindow.View.GoToSlide(oSld.SlideIndex)

Basically, you go to the slide to force a refresh.  2007 has some bugs that may prevent that from working.  In that case, try moving a shape off the slide, refresh, then move it back, or add a shape, refresh, delete.

Was this answer helpful?

0 comments No comments

4 additional answers

Sort by: Most helpful
  1. Anonymous
    2016-12-01T15:18:48+00:00

    With ActivePresentation.SlideMaster.Shapes("ShapeName")

    .TextFrame.TextRange.Text = "New Text"

    .Apply

    End With

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  2. Anonymous
    2016-12-01T17:09:36+00:00

    .Apply would apply the last picked up format which is likely to give very unexpected results.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2012-07-05T08:41:24+00:00

    I recently found a similar refresh issue in the same view but during a long process that added elements to slides. During this process, I wanted to provide a progress indicator and since modeless forms are not supported by VBA6.5 (Mac) I decided to show the progress by adding a shape with text to the current slide.

    The shape only appeared after the code had finished executing so I tried a huge combination of refresh techniques, including those above, yet none worked.

    Finally, this simple delay insertion worked: (for simplicity, the code for each of the sub-procedures in the Main() procedure is omitted:

    Private Sub Main()

    ' Show progress message on current slide

    AddShapeToSlide

    ' Insert a delay of 0.1 seconds so that the above shape is visible on the slide at runtime

    Delay 0.1

    ' Run Procedure 1

    Procedure1

    ' Remove progress message

    DeleteShapeFromSlide

    End Sub

    Private Sub Delay(Seconds As Single)

    Dim TimeNow As Long

    TimeNow = Timer

    Do While Timer < TimeNow + Seconds

    DoEvents

    Loop

    End Sub

    I don't know why this works but it does.  It would be better to have a Repaint command for ActiveWindow like there is for forms.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2012-01-16T18:59:40+00:00

    Thanks Steve,

    I had tried using:

        Activewindow.View.GoToSlide(ActiveWindow.View.Slide.SlideIndex)

    but that didn't work... I think I was hitting the 2007 bug you mentioned.  I found just adding and deleting a shape worked:

        Dim ActiveSlide As Slide, shp As Shape

        Set ActiveSlide = ActivePresentation.Slides(ActiveWindow.View.Slide.SlideIndex)

        ActivePresentation.SlideMaster.Shapes("myShape").TextFrame.TextRange.Text = “New text”

    'Refresh the screen by adding then deleting a shape:

        Set shp = ActiveSlide.Shapes.AddLine(0, 0, 0, 1)

        shp.Delete

    Thanks again.

    Cheers

    Rich

    Was this answer helpful?

    0 comments No comments