none
updating powerpoint textbox and animation RRS feed

  • Question

  • Hi, I have a presentation with 2 slides. They advance automatically every 5 seconds. On each slide, i have a text box that I update from code. That textbox has some animation (e.g. appear on slide). 

    So you would expect that the slide 1 is shown for 5 seconds, and then it goes to slide 2. 

    But my timer is updating every 1 second the content of the textbox and is causing that the slide duration is reset somehow. The result is that the slide remain on slide 1. How can I fix this unexpected behavior?

    Imports Microsoft.Office.Interop.PowerPoint

    Public Class ThisAddIn

      Dim WithEvents tmrRefresh As System.Windows.Forms.Timer

      Private Sub ThisAddIn_Startup() Handles Me.Startup

      End Sub

      Private Sub ThisAddIn_Shutdown() Handles Me.Shutdown

      End Sub

      Private Sub Application_SlideShowBegin(Wn As SlideShowWindow) Handles Application.SlideShowBegin
        If tmrRefresh Is Nothing Then
          tmrRefresh = New System.Windows.Forms.Timer
          tmrRefresh.Interval = 1000 'Every 1 second
          tmrRefresh.Start()
        End If
      End Sub

      Private Sub Application_SlideShowEnd(Pres As Presentation) Handles Application.SlideShowEnd
        If tmrRefresh IsNot Nothing Then
          tmrRefresh.Stop()
          tmrRefresh = Nothing
        End If
      End Sub

      Private Sub tmrRefresh_Tick(sender As Object, e As EventArgs) Handles tmrRefresh.Tick
        Try

          For Each osl As PowerPoint.Slide In Globals.ThisAddIn.Application.ActivePresentation.Slides
            For Each osh As PowerPoint.Shape In osl.Shapes
              If osh.Type = Microsoft.Office.Core.MsoShapeType.msoTextBox Then
                osh.TextFrame.TextRange.Text = Now.Second
              ElseIf osh.Type = Microsoft.Office.Core.MsoShapeType.msoPlaceholder Then
                If osh.PlaceholderFormat.ContainedType = Microsoft.Office.Core.MsoShapeType.msoTextBox Or osh.PlaceholderFormat.ContainedType = Microsoft.Office.Core.MsoShapeType.msoAutoShape Then
                  osh.TextFrame.TextRange.Text = Now.Second
                End If
              End If
            Next
          Next

        Catch ex As Exception

        End Try
      End Sub

    End Class

    Friday, February 23, 2018 3:04 PM

Answers

  • Hello Kurt Dupont,

    What about using a text box for setting value and another shape back of the text box for animation?

    Since the shape is not text box, the add-in will not set its value and so it won't reset the duration.

    For instance.

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Kurt Dupont Thursday, March 1, 2018 11:46 AM
    Thursday, March 1, 2018 7:23 AM

All replies

  • Hello Kurt Dupont,

    I could reproduce your issue.

    It seems that it is by design that update content in textbox in slideshow will reset the slide duration and I think it could not be changed.

    As workaround, I would suggest you use a gif to fill the textbox to make the text "animation".

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, February 27, 2018 10:14 AM
  • But a gif will not work for my type of projects. Here is it a sample with seconds, but it can be anything from a database, so real dynamic. So using a GIF instead is not an option.
    Tuesday, February 27, 2018 10:26 AM
  • Hello Kurt Dupont,

    What about using a text box for setting value and another shape back of the text box for animation?

    Since the shape is not text box, the add-in will not set its value and so it won't reset the duration.

    For instance.

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Kurt Dupont Thursday, March 1, 2018 11:46 AM
    Thursday, March 1, 2018 7:23 AM
  • That is indeed a workable fix! Thanks.
    Thursday, March 1, 2018 11:46 AM