View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
RB Smissaert RB Smissaert is offline
external usenet poster
 
Posts: 2,452
Default SendKeys and Application.ScreenUpdating

What you can do is use API calls to freeze the screen. This freezes the
screen better, but has the drawback that if something goes wrong you are
stuck with a frozen screen and have to come out with Ctrl + Alt + Del. Also
you have to unfreeze the screen before for example a MsgBox.

Put this in the declarations (top of the module):

Private Declare Function LockWindowUpdate Lib "USER32" (ByVal hwndLock As
Long) As Long
Private Declare Function GetDesktopWindow Lib "USER32" () As Long

Then put this Sub somewhere in your module:

Sub WindowUpdating(Enabled As Boolean)

'Completely Locks the Whole Application Screen Area, including dialogs
and the mouse.

Dim Res As Long

If Enabled Then
LockWindowUpdate 0 'Unlock screen area
Else
Res = LockWindowUpdate(GetDesktopWindow) 'Lock at desktop level
End If

End Sub

Then use it in your code like this:

WindowUpdating (False) 'to freeze the screen

or:

WindowUpdating (True) 'to unfreeze the screen



RBS





"Michael Malinsky" wrote in message
oups.com...
I have a module in which I'm using SendKeys to change a printer
property. At the beginning of the module, I have
Application.ScreenUpdating = False so hide the various dialog boxes
that open and close during the process. The problem is that the
ScreenUpdating command looks to be ignored as I can see everything that
is happening.

Any help is appreciated.

TIA,
Mike.