Consulting

Results 1 to 6 of 6

Thread: Application.ScreenUpdating

  1. #1
    VBAX Regular
    Joined
    Sep 2004
    Posts
    10
    Location

    Application.ScreenUpdating

    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.

  2. #2
    VBAX Mentor
    Joined
    Sep 2004
    Location
    Nashua, NH, USA
    Posts
    489
    Location
    Quote Originally Posted by SeanS
    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.

  3. #3
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    Application.ScreenUpdating only became available with MS Project 2002, so you're out of luck with '98.
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  4. #4
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Quote Originally Posted by Howard Kaikow
    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.

  5. #5
    VBAX Mentor
    Joined
    Sep 2004
    Location
    Nashua, NH, USA
    Posts
    489
    Location
    Quote Originally Posted by firefytr
    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.

  6. #6
    VBAX Regular zilpher's Avatar
    Joined
    Nov 2004
    Location
    Swindon, UK
    Posts
    30
    Location
    You don't have to lock the entire desktop if you use LockWindowUpdate (you do have to be careful of course)

    [VBA]
    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
    [/VBA]

    HTH

    Z

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •