PDA

View Full Version : Application.ScreenUpdating



SeanS
10-11-2004, 06:40 AM
I use this property a lot in Excel to stop any screen changes being shown to the user as a macro is running.

I have found that this isn't available in MSP 98. Does anyone know of a way to stop any screen changes being visible to the user in MS Project as a macro is running??

Thanks, Sean.

Howard Kaikow
10-11-2004, 07:37 AM
I use this property a lot in Excel to stop any screen changes being shown to the user as a macro is running.

I have found that this isn't available in MSP 98. Does anyone know of a way to stop any screen changes being visible to the user in MS Project as a macro is running??

Thanks, Sean.
You can do this with API calls, but that can lead to issues.

TonyJollans
10-11-2004, 11:28 PM
Application.ScreenUpdating only became available with MS Project 2002, so you're out of luck with '98.

Zack Barresse
10-27-2004, 10:40 PM
You can do this with API calls, but that can lead to issues.

Hello Howard/Harold, ;)

Could you elaborate on what you mean by 'issues'? Application specific? Curious. :)

Howard Kaikow
10-28-2004, 05:01 AM
Hello Howard/Harold, ;)

Could you elaborate on what you mean by 'issues'? Application specific? Curious. :)
The API calls affect more than just Word, i.e., they may lock the entire desktop.

zilpher
11-17-2004, 12:36 PM
You don't have to lock the entire desktop if you use LockWindowUpdate (you do have to be careful of course)


Option Explicit

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long

Sub LockProject()
'To lock a window we'll use the LockWindowUpdate function, part of the Win32 API
'It accepts an argument that is a long, this refers to the handle of the window
'to be locked. Here is a variable to store the handle:
Dim lngHandle As Long
'lockwindowupdate returns a zero if it failed, so heres a container for checking
'the return
Dim Ret As Long
'we'll use this in the "error trap"
Dim blnTriedAlready As Boolean

'To find the handle for the Project window we'll use the FindWindow function, again part
'of the Win32 API. This function accepts two arguments, the Classname and the caption of the window

'I have Project 2002, the class name of the MS Project window is JWinproj-WhimperMainClass
'I have no idea what it might be for other versions of Project.
'You can use a null string when trying to find the handle for the window but you run the
'risk of there being another window with exactly the same caption.
lngHandle = FindWindow("JWinproj-WhimperMainClass", Application.Caption)
'lngHandle = FindWindow(vbNullString, Application.Caption)

If lngHandle = 0 Then
MsgBox "Failed to get handle for window"
Exit Sub
End If

TRYAGAIN:
Ret = LockWindowUpdate(lngHandle)

'if LockWindowUpdate fails, it will return zero, which might mean there is another
'window locked, so reset and try again
If Ret = 0 And Not blnTriedAlready Then
LockWindowUpdate False
blnTriedAlready = True
GoTo TRYAGAIN
Else
MsgBox "Failed to lock the window"
End If
End Sub

Sub UnlockProject()
LockWindowUpdate False
End Sub


HTH

Z