Screen updating excel
Example 1 you can use in Excel 97-2016 , Example 2 you can use in Excel 2000-2016.If you run the code in Excel 2007-2016 it will look at the File Format of the parent workbook and save the new file in that format. Cut Copy Mode = False Temp File Path = Application.In Excel 2007-2016, Save As requires you to provide both the File Format parameter and the correct file extension.For example, in Excel 2007-2016, this will fail if the Active Workbook is not an xlsm file' 52 = xl Open XMLWorkbook Macro Enabled = xlsm (with macro's in 2007-2016) These are the main file formats in Excel 2007-2016, Note: In Excel for the Mac the values are 151 = xl Open XMLWorkbook (without macro's in 2007-2016, xlsx)52 = xl Open XMLWorkbook Macro Enabled (with or without macro's in 2007-2016, xlsm) 50 = xl Excel12 (Excel Binary Workbook in 2007-2016 with or without macro's, xlsb)56 = xl Excel8 (97-2003 format in Excel 2007-2016, xls)Note: I always use the File Format numbers instead of the defined constants in my code so that it will compile OK when I copy the code into an Excel 97-2003 workbook (For example, Excel 97-2003 won't know what the xl Open XMLWorkbook Macro Enabled constant is).Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
' -------------------------------------------------------------------------------- ' You are free to use this code within your own applications, add-ins, ' documents etc but you are expressly forbidden from selling or ' otherwise distributing this source code without prior consent.Declare Function Find Window Lib "user32" Alias "Find Window A" _ (By Val lp Class Name As String, _ By Val lp Window Name As Long) As Long ' Use Lock Window Update to prevent/enable window refresh Declare Function Lock Window Update Lib "user32" _ (By Val hwnd Lock As Long) As Long ' Use Update Window to force a refresh of the Power Point window Declare Function Update Window Lib "user32" (By Val hwnd As Long) As Long Property Let Screen Updating(State As Boolean) Static hwnd As Long Dim Version No As String ' Get Version Number If State = False Then Version No = Left(Application. Version, ".") - 1) ' Get handle to the main application window using Class Name Select Case Version No Case "8" ' For PPT97: hwnd = Find Window("PP97Frame Class", 0&) Case "9" ' For PPT2K: hwnd = Find Window("PP9Frame Class", 0&) Case "10" ' For XP: hwnd = Find Window("PP10Frame Class", 0&) Case "11" ' For 2003: hwnd = Find Window("PP11Frame Class", 0&) Case "12" ' For 2007: hwnd = Find Window("PP12Frame Class", 0&) Case "14" ' For 2010: hwnd = Find Window("PPTFrame Class", 0&) Case "15" ' For 2013: hwnd = Find Window("PPTFrame Class", 0&) Case Else Err.Raise Number:=vb Object Error ERR_VERSION_NOT_SUPPORTED, _ Description:="Newer version." Exit Property End Select If hwnd = 0 Then Err.Open("C:\sample.pps", _ With Window:=mso False) 'Open a window now to the presentation for editing p Show.
New Window ' Unlock the window to start refreshing again Screen Updating = True Exit Sub Err Handle: If Err.In Excel versions before Excel 2007, code without this parameter will not cause too many problems because Excel will use the current File Format of the existing file and the default File Format for new files is a (xls) in 97-2003 because there are no other Excel file formats before Excel 2007.