ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   SendKeys and Application.ScreenUpdating (https://www.excelbanter.com/excel-programming/325776-sendkeys-application-screenupdating.html)

Michael Malinsky[_2_]

SendKeys and Application.ScreenUpdating
 
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.


RB Smissaert

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.



Fredrik Wahlgren

SendKeys and Application.ScreenUpdating
 

"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.


Application.ScreenUpdating = False will only prevent the cells from showing
updated values.

/Fredrik



Michael Malinsky[_2_]

SendKeys and Application.ScreenUpdating
 
I tried your suggestion, but I can still see the all of the print
dialogs pop up from the SendKeys commands. If I step through it, the
desktop freezes, but when I run the module, it doesn't seem to work.

Any ideas on what I'm missing?

Thanks,
Mike.



All times are GMT +1. The time now is 06:44 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com