CHRIS RAE'S VBA PAGES

Routine Archive


Module:QuitWhenPrinted
Description:Quit as soon as Word has finished printing. Note that if a problem occurs during the print requiring user intervention, the routine will wait until this is complete. Not much I can do about that, I'm afraid.

' Routine stuck together by Chris Rae but entirely based
' upon code and ideas from Jonathan West and Astrid. 20/7/99.
Option Explicit
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub QuitWhenPrinted()
    Do While Application.BackgroundPrintingStatus > 0
        Sleep 1000
    Loop
    Application.Quit
End Sub

You're free to use these routines for anything you want - all I ask is that for commercial use you give me credit somewhere. You may instead want to head back to the index for my Visual Basic for Applications Pages or the main routines archive page.