none
PowerPoint 2016 bug: A sample VBA macro demonstrating how PowerPoint performance degrades RRS feed

  • Question

  • Hello,

    Сreate a new PP presentation, delete the default shapes from the first slide, put 4-5 simple shapes (Insert | Shapes) on the slide, switch to the VBA IDE, add a module to the project, paste the VBA macro below, put the cursor within the Test macro, and press F5. Open the Immediate window and see the time spent on executing the code. Now press F5 again and again and again. In PowerPoint 2016 Version 1708 (8410.1000 Click-to-Run and 8414.1000 Click-to-Run) 32bit, the time steadily grows.

    As you can see the VBA macro just re-positions the shapes:

    Option Explicit
    
    Const loopLimit As Integer = 500
    Const tempTop1 As Single = 17
    Const tempTop2 As Single = 450
    Private Declare Function GetTickCount Lib "kernel32" () As Long
    
    Sub Test()
    Dim startTime As Long
        startTime = GetTickCount()
    
    Dim sld As PowerPoint.Slide
        Set sld = Application.ActiveWindow.View.Slide
    Dim shps As PowerPoint.Shapes
        Set shps = sld.Shapes
    Dim shp As PowerPoint.Shape
    Dim i As Integer
    Dim j As Integer
        For j = 1 To loopLimit
            For i = 1 To shps.Count
                Set shp = shps.Item(i)
                If shp.Top <> tempTop1 Then
                    shp.Top = tempTop1
                Else
                    shp.Top = tempTop2
                End If
                Set shp = Nothing
            Next i
        Next j
    Dim elapsed As Long
        elapsed = GetTickCount - startTime
        
        Debug.Print "Time elapsed" + " = " + CStr(elapsed / 1000)
    End Sub
    


    Regards from Belarus (GMT + 3),

    Andrei Smolin
    Add-in Express Team Leader

    Please mark answers and useful posts to help other developers use the forums efficiently.

    Wednesday, July 26, 2017 10:35 AM

All replies

  • Hello,

    I think it has something to do with the undo info that is stored.

    If you put a save after executing your code, the time spend looks the same, and the undo info is erased.

    Some way to disable the undo function would help, but I don't know how to do this in VBA

    Best regards,

    Wouter

    Wednesday, July 26, 2017 2:03 PM
  • Hello,

    Testing the code in Office 2007-2016, i get the same result. The time shows rising trend. I try to follow Wouter 's suggestion to save after executing, but it make no difference. The code would run faster if UI has some changes.

    What is your expected result and why do you re-position these shapes?

    Regards,

    Celeste


    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.

    Thursday, July 27, 2017 9:15 AM
    Moderator

  • What is your expected result and why do you re-position these shapes?

    Hi Celeste,

    Sorry for jumping in, but the question asked by Andrei has been motivated by my experience developing an add-in that needs to recreate and reposition a high number of shapes in a presentation. I sent Andrei some Delphi code suspecting the problem was on my code, but he has discovered that the problem resides in PowerPoint. I also suspected that the problem might be related to undo information and I also tried to save after running the code without success, but closing and reopening the presentation "resets" the timings.

    On my real add-in, a typical scenario is copying a few hundred shapes from a custom layout to several slides and then moving them around and changing their text. The performance problem becomes noticeable after a few executions.

    If I could understand where is the problem, maybe I can redesign the way my add-in works to minimize it.

    On another, totally unrelated issue. I have placed an alert on this thread but I am not receiving emails when there are answers. That is why I didn't react before. How do I ensure that I get the alerts?

    Sunday, July 30, 2017 9:40 PM
  • Hello Celeste,

    Like Manuel (Hello Manuel!), I don't receive notifications on this topic.Could you please look into this as well?

    The issue was originally reproduced on a real add-in that moves and updates multiple shapes according to its business logic. The VBA macro is an intentionally simplified version of that add-in; the loop is used to make processing time perceptible. As a developer, I expect that every run of the macro above requires [almost] the same time. I don't expect that the processing time grows (only grows). It is unacceptable that the end user can notice this growth.


    Regards from Belarus (GMT + 3),

    Andrei Smolin
    Add-in Express Team Leader

    Please mark answers and useful posts to help other developers use the forums efficiently.

    Thursday, August 3, 2017 2:52 PM
  • Hello Manuel and Andrei,

    I didn't get any email alert for this thread either. Sorry that there is nothing I can do.

    About PowerPoint issue, I have invited some senior engineers. It will take some time. Your patience will be greatly appreciated.

    Regards,

    Celeste


    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.

    Friday, August 4, 2017 7:25 AM
    Moderator
  • Hello Andrei,

    I tried to reproduce the problem at my end. I could replicate the problem but to confirm if it is a bug or by design issue it requires considerable amount of time to debug/troubleshoot.

    Because of its complexity your question falls into the paid support category which requires a more in-depth level of support.  If the support engineer determines that the issue is the result of a bug the service request will be a no-charge case and you won't be charged. Please visit the below link to see the various paid support options that are available to better meet your needs. http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone

    Tuesday, August 29, 2017 12:11 PM