Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Suppressing the Print Message Box

178 views
Skip to first unread message

David Bortfeld

unread,
Sep 22, 2000, 3:00:00 AM9/22/00
to
I am printing a number of pages under VBA control and do not want to
have the Print Message Box pop up each time (I am using a Progress
Indicator). Application.DisplayAlerts = False does not help. Any
ideas? Thanks.

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

Stratos Malasiotis

unread,
Sep 22, 2000, 3:00:00 AM9/22/00
to David Bortfeld
Hi David,

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
'----------------------------

0 new messages