Turn off screenupdating for Powerpoint

前端 未结 2 1060
一生所求
一生所求 2020-12-06 13:02

I am writing a script that loops through a folder and creates graphs from some criteria, and then exports these to powerpoint. At the moment, creating 130 graphs takes 290 s

2条回答
  •  没有蜡笔的小新
    2020-12-06 13:47

    One workaround I found was to minimize the PPT window, and then use EnableWindow to prevent user input getting to it. Tested with Office 365, from VB.NET

    
    Private Shared Function EnableWindow(ByVal hWnd As IntPtr, ByVal bEnable As Boolean) As Boolean
    End Function
    
    Private _pptApp As PowerPoint.Application
    
    Public Property ScreenUpdating As Boolean
    
        Get
            Return _pptApp.WindowState=PpWindowState.ppWindowNormal
        End Get
    
        Set(value As Boolean)
    
            If value Then
                EnableWindow(_pptApp.HWND, True)
                _pptApp.WindowState = PpWindowState.ppWindowNormal
            Else
                'need to make sure it is enabled otherwise changing the state throws an exception
                EnableWindow(_pptApp.HWND, True)
                _pptApp.WindowState = PpWindowState.ppWindowMinimized
                EnableWindow(_pptApp.HWND, False)
            End If
    
        End Set
    
    End Property
    

提交回复
热议问题