【问题标题】:PowerPoint 2013 Macro Runs Slow (redrawing issue?)PowerPoint 2013 宏运行缓慢(重绘问题?)
【发布时间】:2015-11-02 17:43:30
【问题描述】:

我有一个宏可以让页面上的每个形状都可见(我还有其他宏可以让它们不可见)。代码如下:

Dim Slide As Integer
Slide = SSW.View.CurrentShowPosition
If Slide = 1 Then
    For Each shp In ActivePresentation.Slides(2).Shapes
        shp.Visible = True
    Next shp
End if

这个宏需要 forever 才能运行。我怀疑这是因为每次显示形状时它都会重新绘制屏幕。

这不是必需的,事实上,当此宏运行时,幻灯片甚至不会显示在屏幕上(它在幻灯片 1 上运行,但使幻灯片 2 上的形状可见)。有没有办法让这个运行更快?禁用屏幕刷新还是什么?

我从http://www.vbaexpress.com/forum/showthread.php?33671-Solved-PP2010-ScreenUpdating-False 尝试了 Shyam 的解决方案,但它不起作用。他只到 2010 年,我用的是 2013 年。

【问题讨论】:

    标签: vba powerpoint


    【解决方案1】:

    您的代码无法正常工作。我把它改成了这个,它几乎可以在一张有 175 种形状的幻灯片上立即生效:

    ' Put this at the top of every module; builds character, keeps you out of trouble
    Option Explicit  
    
    Sub ThisWorks()
    
    ' Always dim ALL variables
    Dim Slide As Long   ' SlideIndex is a Long, not an Integer
    Dim oSh As Shape
    
    ' Replaced your SSW with this:
    Slide = SlideShowWindows(1).View.CurrentShowPosition
    If Slide = 1 Then
        For Each oSh In ActivePresentation.Slides(2).Shapes
            ' I was toggling them back and forth as a test
            ' oSh.Visible = Not oSh.Visible
            oSh.Visible = True
        Next
    End If
    
    ' Delete this when it's no longer needed
    MsgBox "Done"
    
    End Sub
    

    【讨论】:

    • 代码不起作用的原因是我忘记包含将 SSW 变量设置为 SlideShowWindows(1) 的行。我现在不在工作,明天我会试试你的新代码,让你知道它是否有效。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多