suppress "now outputting" and "now printing" dialog windows

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • n8kindt
    New Member
    • Mar 2008
    • 221

    suppress "now outputting" and "now printing" dialog windows

    how do i suppress the outputting and printing dialog boxes that pop up while running vba code such as:

    Code:
    DoCmd.OpenReport "Report1"
    or
    Code:
    DoCmd.OutputTo acOutputReport, "Report1", acFormatPDF, Filename, False
    i tried a suggestion to use this code i found on another website:

    Code:
    Option Compare Database
    Option Explicit
    
    Private Declare Function GetDesktopWindow Lib "user32" () As Long
    Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long
    
    
    Sub DisablePrintDialog(DisableIt as boolean)
    on error goto Err_Trap
    if DisableIt then
                LockWindowUpdate (GetDesktopWindow)
    else
                LockWIndowUpdate (False)
    end if
    exit sub
    
    Err_Trap
    msgbox err.number & ": " & err.description
    Resume Next
    
    end sub
    but the dialog box still popped up with a blank face. on top of that, it made my vba editor behave very oddly even after i turned the suppression back off.

    if someone could please tell me how i could do this, that would be really great. and if someone also knows where i can learn/find code related to window messages in office and in windows like this i would be very appreciative. thank you!

    --nate
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Here is an answer from the talented Author Dev Ashish. I've tested his code on the Invoice Report (1,662 pages) of the sample Northwind Database and it works as intended. I output this Report to *.pdf Format to simulate what you have stated.

    API: Suppress the "Printing" Dialog

    NOTE: Be advised that it involves the use of several API Functions, and is not for the faint of heart!

    Comment

    • n8kindt
      New Member
      • Mar 2008
      • 221

      #3
      Originally posted by ADezii
      Here is an answer from the talented Author Dev Ashish. I've tested his code on the Invoice Report (1,662 pages) of the sample Northwind Database and it works as intended. I output this Report to *.pdf Format to simulate what you have stated.

      API: Suppress the "Printing" Dialog

      NOTE: Be advised that it involves the use of several API Functions, and is not for the faint of heart!
      alright ADezii! you rock! I can't wait to get my hands dirty with this one :). that's a great website, too. double bonus! thanks so much!

      cheers,
      Nate

      Comment

      • ADezii
        Recognized Expert Expert
        • Apr 2006
        • 8834

        #4
        Originally posted by n8kindt
        alright ADezii! you rock! I can't wait to get my hands dirty with this one :). that's a great website, too. double bonus! thanks so much!

        cheers,
        Nate
        You are quite welcome. I'm actually creating a Test Database illustrating this code, since I may use this functionality in the future. As soon as I finish it, I'll make it available to you as an Attachment. Please keep in mind that the code Author is Dev Ashish, and not me, do not modify it, and keep the Copyright notice intact. Will keep in touch.

        Comment

        • ADezii
          Recognized Expert Expert
          • Apr 2006
          • 8834

          #5
          n8kindt, when you get a chance, download the Attachment. I think you'll like what you see. Should you need any code explanations, I'll be available.

          Comment

          • n8kindt
            New Member
            • Mar 2008
            • 221

            #6
            Originally posted by ADezii
            n8kindt, when you get a chance, download the Attachment. I think you'll like what you see. Should you need any code explanations, I'll be available.
            thanks, ADezii. i was going to do this later on in the week or weekend but you made it so easy i just had to try it out. it definitely works. unfortunately, since my report has such a busy query behind it, the good ol' hour glass comes up right as soon as the dialog message comes up, and freezes the display until the report is generated. i tried knocking the timer even clear down to 1ms but i received the same result.

            it's too bad there isn't an event for reports called "On Print" or "On Output". i tried messing with the "OnPage" event in the report (which is supposed to fire after the report is output but BEFORE it is printed) but even though that seemed to kill the window a smidge quicker it did not keep the window being open the entire time the report is being generated. however, i am perfectly content with the way it is b/c it does aid in showing the progress of the program. the best part about this code is the cancel option is effectively disabled without having to show a blank window that just raises question marks in the user's head.

            well, that does it for me, ADezii. if you have any suggestions off the top of your head on how to eliminate the message that is fine, but it's not worth any more effort when this will suit me just fine. i greatly appreciate your expertise and thanks again for the time you put into this.

            cheers,
            nate

            ps- i had a good laugh when i saw the super large button caption. good stuff lol.

            Comment

            • ADezii
              Recognized Expert Expert
              • Apr 2006
              • 8834

              #7
              Originally posted by n8kindt
              thanks, ADezii. i was going to do this later on in the week or weekend but you made it so easy i just had to try it out. it definitely works. unfortunately, since my report has such a busy query behind it, the good ol' hour glass comes up right as soon as the dialog message comes up, and freezes the display until the report is generated. i tried knocking the timer even clear down to 1ms but i received the same result.

              it's too bad there isn't an event for reports called "On Print" or "On Output". i tried messing with the "OnPage" event in the report (which is supposed to fire after the report is output but BEFORE it is printed) but even though that seemed to kill the window a smidge quicker it did not keep the window being open the entire time the report is being generated. however, i am perfectly content with the way it is b/c it does aid in showing the progress of the program. the best part about this code is the cancel option is effectively disabled without having to show a blank window that just raises question marks in the user's head.

              well, that does it for me, ADezii. if you have any suggestions off the top of your head on how to eliminate the message that is fine, but it's not worth any more effort when this will suit me just fine. i greatly appreciate your expertise and thanks again for the time you put into this.

              cheers,
              nate

              ps- i had a good laugh when i saw the super large button caption. good stuff lol.
              ps- i had a good laugh when i saw the super large button caption. good stuff lol.
              Just want to make sure that the End User knows which Button to click! (LOL). I use the exact Template for all Test Databases.

              Comment

              • blah DeBlah
                New Member
                • Jan 2012
                • 9

                #8
                very exremely cool but correct me if I'm wrong: if windows tries to send you another message -- such as a dialog for ODBC credentials, which sometimes cannot be avoided -- it will also be hidden.

                [edit]

                it is true. it's a very cool solution, but I notice that "ghost" dialogues still get painted and as mentioned above (and I think Dev states this) it's a complete blackout of Window updates -- not merely that little print nag.

                and I guess I'm posting this 3 years on because the software powerhouses still haven't bothered to clean up *that* detail, either.

                Comment

                • blah DeBlah
                  New Member
                  • Jan 2012
                  • 9

                  #9
                  edit my previous: those comments apply to a different "hide window" bit that Dev has out there -- I think it's called "hide print window" or something similar.

                  This does in fact isolate the print window -- it's not a general screen updating freeze. However, as others have pointed out, it isn't able to capture every print window when they're run in large numbers.

                  Very cool code, however. Probably the best attempt possible, given the meager tools we have to deal with.

                  Comment

                  Working...