DISABLE PRINTING DIALOGUE BOX

Mark O'Brien

MrExcel MVP
Joined
Feb 15, 2002
Messages
3,530
Could you post a bit of the code that displays the Print dialogue box please? I'm not sure if I fully understand.
Thanks.
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
I have a macro that sorts a large report and prints each sorted copy. Is there any way to disable the printing dialogue box that opens when each report is printed. I am using a form as a progress bar and the printing dialogue box covers it up momentarily as each report prints. Thanks for you help.
I tried application.displayalerts = false but that didn't disable the box.
 
Upvote 0
Mark, I am referring the the default box that pops up with you print in excel, the one that shows the pages printing etc.
 
Upvote 0
On 2002-04-12 16:52, Eddie G. wrote:
Mark, I am referring the the default box that pops up with you print in excel, the one that shows the pages printing etc.

I think you can do this via API calls.
Its the coding I'm not sure of but would
probably involve a few eg.

Sending a msg to the dialog
disabling a repaint
 
Upvote 0
Try repositioning your progress bar form.

or use the status bar the display the progess as a percentage with:

application.statusbar = x &"%"
 
Upvote 0
I beleive Tom Ogilvy provide the following code to disable the dialog...so I don't
have to look @ creating a routine....I just
commented where i could.

So this routine called in the proper way
(see example should get rid of the dialog
that displays when ever you do a print ie.
the Dialod that comes up saying Print X of Y)

<pre/>

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
'// The SendMessage function sends the specified message to a window or windows.
'// The function calls the window procedure for the specified window and does not
'// return until the window procedure has processed the message.
'// The PostMessage function, in contrast, posts a message to a thread’s message
'// queue and returns immediately.
'//
'// PARAMETERS:
'//
'// hwnd
'// Identifies the window whose window procedure will receive the message.
'// If this parameter is HWND_BROADCAST, the message is sent to all top-level
'// windows in the system, including disabled or invisible unowned windows,
'// overlapped windows, and pop-up windows; but the message is not sent to child windows.

'// Msg
'// Specifies the message to be sent.

'// wParam
'// Specifies additional message-specific information.

'// lParam
'// Specifies additional message-specific information.

'//////////////////////////////////////////////////////////////////////////
'// The IsWindow function determines whether the specified window handle
'// identifies an existing window.
Private Declare Function IsWindow Lib "user32" (ByVal hwnd As Long) As Long
'// PARAMETERS:
'// hWnd
'// Specifies the window handle.

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


'// This is how to use the function
Sub PrintDirect()
fncScreenUpdating State:=False
ActiveWindow.SelectedSheets.PrintOut Copies:=1
fncScreenUpdating State:=True
End Sub
'//

</pre>
 
Upvote 0

Forum statistics

Threads
1,214,522
Messages
6,120,020
Members
448,939
Latest member
Leon Leenders

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top