PowerPoint 2016错误:示例VBA宏演示PowerPoint性能如何降级 [英] PowerPoint 2016 bug: A sample VBA macro demonstrating how PowerPoint performance degrades

查看:107
本文介绍了PowerPoint 2016错误:示例VBA宏演示PowerPoint性能如何降级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

Сreate一个新的PP演示文稿,从第一张幻灯片中删除默认形状,在幻灯片上放置4-5个简单形状(Insert | Shapes),切换在VBA IDE中,将一个模块添加到项目中,粘贴下面的VBA宏,将光标放在Test宏中,然后按
F5。打开立即窗口,查看执行代码所花费的时间。现在再次按F5一次又一次。在PowerPoint 2016版本1708(8410.1000即点即用和8414.1000即点即用)  32bit中,时间稳步增长。

С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.

正如您所看到的那样,只需重新启动VBA宏定位形状:

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






白俄罗斯的问候( GMT + 3),



Andrei Smolin

加载项快递团队负责人



请标记答案和有用的帖子,以帮助其他开发人员有效地使用论坛。



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.

推荐答案

您好,

我认为它与存储的撤消信息有关。

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.

某些禁用撤消功能的方法会有所帮助,但我不知道如何在VBA中执行此操作

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

最佳问候,

Wouter


这篇关于PowerPoint 2016错误:示例VBA宏演示PowerPoint性能如何降级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆