No print message

Airborne

Board Regular
Joined
Apr 22, 2004
Messages
97
Hello, in my macro the workbook that is saved also prints one of the sheets. When the printing starts I get the message document is printed to...Is it possible to add a command so the message will not be shown?
I've tried
Code:
Application.ScreenUpdating = False
But then I see a gray area where the message would be.

Thanks.
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
You need to lines,

Application.Displayalerts = False
Application.ScreenUpdating = False

Then at the end of your code the following,

Application.Displayalerts = True
Application.ScreenUpdating = True


Hope this helps.



Jack
 
Upvote 0
Thanks, I've tried it but I still get the message that the sheet will be printed.

Thanks anyway.
 
Upvote 0
Try something like this

Code:
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
'// 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
'// is Valid.
Private Declare Function IsWindow _
    Lib "user32" ( _
        ByVal hwnd As Long) _
As Long
'// PARAMETERS:
'// -hWnd
'// Specifies the window handle.

'//////////////////////////////////////////////////////////////////////////
'//

'// The InvalidateRect function specifies weather all or part of
'// a rectangle has been updated OR requires updating in a window.
'// The process of notifying a window that an update/refresh is needed
'// is done by this function.
'// hwnd:   handle of Window to Invalidate
'// lpRect: Set to 0 to invalidate Entire Window
'// bErase: TRUE causes specified area to be erased before it is redrawn

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 PrtScreenUpDate(bShowState As Boolean) As Boolean
Dim Wndhdl As Long

Const WM_SETREDRAW = &HB
Const WM_PAINT = &HF

Wndhdl = GetDesktopWindow

If IsWindow(Wndhdl) = False Then Exit Function

If bShowState Then
    SendMessage Wndhdl, WM_SETREDRAW, 1, 0
    InvalidateRect Wndhdl, 0, True
    UpdateWindow Wndhdl
Else
    SendMessage Wndhdl, WM_SETREDRAW, 0, 0
End If

End Function

'Call it like this.....
'-----------------------------
Sub PrintTestDisableDialog()
    PrtScreenUpDate False
    ActiveWindow.SelectedSheets.PrintOut Copies:=1
    PrtScreenUpDate True
End Sub
'-----------------------------
 
Upvote 0
isn't there a line in your original code saying something like: Msgbox ("file is printed to...")

Not sure I'm on the right track here, but it seems just like an aweful lot of code just to hide one message.
 
Upvote 0
The code is for not showing the message that the sheet will be printed.
I noticed though, that the whole system stops when for some reason the printer is down. So there must be something added that will stop the macro when the printer is down.[/u]
 
Upvote 0

Forum statistics

Threads
1,215,339
Messages
6,124,365
Members
449,155
Latest member
ravioli44

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