PRINT DIALOGUE BOX
Upcoming Power Excel Seminars
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: PRINT DIALOGUE BOX

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Location
    OKC
    Posts
    98
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I posted this earlier but I don't see it. Sorry if this is a duplicate.....can the print dialogue box be hidden during printing? I have a macro that sorts and prints each report and I use a form as a progress status bar. As each report prints, the status bar is blocked by the print dialogue box. Can excel print without showing the dialogue box?

  2. #2
    Board Regular
    Join Date
    Mar 2002
    Location
    Brampton
    Posts
    328
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Set the ScreenUpdating property to false at the beginning of the macro, and reset the property value to true at the end.

  3. #3
    MrExcel MVP Ivan F Moala's Avatar
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    4,209
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    ††
    On 2002-07-10 21:06, Corni wrote:
    Set the ScreenUpdating property to false at the beginning of the macro, and reset the property value to true at the end.
    Unfortunately this will not work as the
    Window that is displayed is NOT part of the Applications windows/child.
    You need to accomplish this via some API calls that Identify the window and esentailly hides it.


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

    'Call it like this
    '-----------------------------
    Sub PrintDirect()
    fncScreenUpdating State:=False
    ActiveWindow.SelectedSheets.PrintOut Copies:=1
    fncScreenUpdating State:=True
    End Sub
    '-----------------------------




    Kind Regards,
    Ivan F Moala From the City of Sails

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 

DMCA.com