Connecting Tech Pros Worldwide Forums | Help | Site Map

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

n8kindt's Avatar
Familiar Sight
 
Join Date: Mar 2008
Location: Southern California
Posts: 221
#1: Jun 30 '08
how do i suppress the outputting and printing dialog boxes that pop up while running vba code such as:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "Report1"
or
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OutputTo acOutputReport, "Report1", acFormatPDF, Filename, False
i tried a suggestion to use this code i found on another website:

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Private Declare Function GetDesktopWindow Lib "user32" () As Long
  5. Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long
  6.  
  7.  
  8. Sub DisablePrintDialog(DisableIt as boolean)
  9. on error goto Err_Trap
  10. if DisableIt then
  11.             LockWindowUpdate (GetDesktopWindow)
  12. else
  13.             LockWIndowUpdate (False)
  14. end if
  15. exit sub
  16.  
  17. Err_Trap
  18. msgbox err.number & ": " & err.description
  19. Resume Next
  20.  
  21. 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's Avatar
Expert
 
Join Date: Apr 2006
Location: Philadelphia
Posts: 5,216
#2: Jul 2 '08

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


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!
n8kindt's Avatar
Familiar Sight
 
Join Date: Mar 2008
Location: Southern California
Posts: 221
#3: Jul 2 '08

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


Quote:

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
ADezii's Avatar
Expert
 
Join Date: Apr 2006
Location: Philadelphia
Posts: 5,216
#4: Jul 2 '08

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


Quote:

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.
ADezii's Avatar
Expert
 
Join Date: Apr 2006
Location: Philadelphia
Posts: 5,216
#5: Jul 2 '08

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


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.
n8kindt's Avatar
Familiar Sight
 
Join Date: Mar 2008
Location: Southern California
Posts: 221
#6: Jul 2 '08

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


Quote:

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.
ADezii's Avatar
Expert
 
Join Date: Apr 2006
Location: Philadelphia
Posts: 5,216
#7: Jul 3 '08

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


Quote:

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.

Quote:
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.
Reply