<p>When I use the PrintOut method to print a Worksheet object to a printer, the "Printing" dialog (showing filename, destination printer, pages printed and a Cancel button) is displayed even though I have set DisplayAlerts = False.  The code below works in an Excel macro but the same thing happens if I use this code in a VB or VB.Net application (with the reference changes required to use the Excel object).</p>

<pre><code>Public Sub TestPrint()
Dim vSheet As Worksheet

    Application.ScreenUpdating = False
    Application.DisplayAlerts = False

    Set vSheet = ActiveSheet
    vSheet.PrintOut Preview:=False

    Application.DisplayAlerts = True
    Application.ScreenUpdating = True

End Sub
</code></pre>

<p>EDIT: The answer below sheds more light on this (that it may be a Windows dialog and not an Excel dialog) but does not answer my question.  Does anyone know how to prevent it from being displayed?</p>

<p>EDIT: Thank you for your extra research, Kevin. It looks very much like this is what I need.  Just not sure I want to blindly accept API code like that. Does anyone else have any knowledge about these API calls and that they're doing what the author purports?</p>

[{'answer_id': 69726, 'author': 'Kevin Haines', 'author_id': 10410, 'author_profile': 'https://Stackoverflow.com/users/10410', 'pm_score': 2, 'selected': True, 'text': '<p>When you say the "Printing" Dialog, I assume you mean the "Now printing xxx on " dialog rather than standard print dialog (select printer, number of copies, etc). Taking your example above &amp; trying it out, that is the behaviour I saw - "Now printing..." was displayed briefly &amp; then auto-closed.</p>\n\n<p>What you\'re trying to control may not be tied to Excel, but instead be Windows-level behaviour. If it is controllable, you\'d need to a) disable it, b) perform your print, c)  re-enable. If your code fails, there is a risk this is not re-enabled for other applications.</p>\n\n<p>EDIT: Try this solution: <a href="http://www.mrexcel.com/archive2/11900/13336.htm" rel="nofollow noreferrer">How do you prevent printing dialog when using Excel PrintOut method</a>. It seems to describe exactly what you are after.</p>\n'}, {'answer_id': 115088, 'author': 'Robert S.', 'author_id': 7565, 'author_profile': 'https://Stackoverflow.com/users/7565', 'pm_score': 1, 'selected': False, 'text': "<p>The API calls in the article linked by Kevin Haines hide the Printing dialog like so:</p>\n\n<ol>\n<li>Get the handle of the Printing dialog window.</li>\n<li>Send a message to the window to tell it not to redraw</li>\n<li>Invalidate the window, which forces a redraw that never happens</li>\n<li>Tell Windows to repaint the window, which causes it to disappear.</li>\n</ol>\n\n<p>That's oversimplified to put it mildly.</p>\n\n<p>The API calls are safe, but you will probably want to make sure that screen updating for the Printing dialog is set to True if your application fails.</p>\n"}, {'answer_id': 12731485, 'author': 'Raghbir Singh', 'author_id': 1720679, 'author_profile': 'https://Stackoverflow.com/users/1720679', 'pm_score': 2, 'selected': False, 'text': "<p>If you don't want to show the print dialogue, then simply make a macro test as follows; it won't show any print dialogue and will detect the default printer and immediately print.</p>\n\n<pre><code>sub  test()\n\n activesheet.printout preview:= false\n\nend sub\n</code></pre>\n\n<p>Run this macro and it will print the currently active sheet without displaying the print dialogue.</p>\n"}]
['https://Stackoverflow.com/questions/67219', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7209/']