--
David P Bortfeld
Program Manager, Sarnoff Corporation
CN 5300, Princeton NJ 08543-5300
Tel: 609-734-2515
Fax: 609-734-2049
email: dbor...@sarnoff.com
Application.DisplayAlerts = False will not work since this is not an alert; just something like a progress bar.
I had a similar problem with the dialogs when you export charts and also sometimes I wanted to stop the repainting of specific controls on
userforms.
I have adjusted my solution to your problem, below. Maybe there is an easier solution tho..
HTh
Stratos
p.s. if you try to play with it to much and you get into problems. Use Alt+Ctrl+Del and then Cancel
The fncScreenUpdating sets the repainting window flag to false and therefore no WM_PAINT reaches the winproc
'-----------------------------
Sub PrintDirect()
fncScreenUpdating State:=False
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
fncScreenUpdating State:=True
End Sub
'-----------------------------
'----------------------------
Option Explicit
Private Declare Function SendMessage _
Lib "user32" _
Alias "SendMessageA" _
( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any _
) _
As Long
Private Declare Function IsWindow _
Lib "user32" _
( _
ByVal hwnd As Long _
) _
As Long
Private Declare Function InvalidateRect _
Lib "user32" _
( _
ByVal hwnd As Long, _
lpRect As Long, _
ByVal bErase As Long _
) _
As Long
Private Declare Function UpdateWindow _
Lib "user32" _
( _
ByVal hwnd As Long _
) _
As Long
Private Declare Function GetDesktopWindow _
Lib "user32" () _
As Long
Public Function fncScreenUpdating _
( _
State As Boolean, _
Optional Window_hWnd As Long = 0 _
)
Const WM_SETREDRAW = &HB
Const WM_PAINT = &HF
If Window_hWnd = 0 Then
Window_hWnd = GetDesktopWindow()
Else
If IsWindow(hwnd:=Window_hWnd) = False Then
Exit Function
End If
End If
If State = True Then
Call SendMessage _
( _
hwnd:=Window_hWnd, _
wMsg:=WM_SETREDRAW, _
wParam:=1, _
lParam:=0 _
)
Call InvalidateRect _
( _
hwnd:=Window_hWnd, _
lpRect:=0, _
bErase:=True _
)
Call UpdateWindow(hwnd:=Window_hWnd)
Else
Call SendMessage _
( _
hwnd:=Window_hWnd, _
wMsg:=WM_SETREDRAW, _
wParam:=0, _
lParam:=0 _
)
End If
End Function
'----------------------------