Results 1 to 4 of 4

Thread: stall between printing and closing

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2006
    Posts
    39

    stall between printing and closing

    I have an open document that I want printed and then closed. here is the code

    VB Code:
    1. ActiveDocument.PrintOut
    2.     Kill "temp.doc"
    3.     ActiveDocument.Close False
    4.     Application.Quit False

    I want it to print the active document, delete the temp.doc file, close the document and then close word.The problem is it all happens too fast that it doesn't print the active document.

    Any ideas on how to do this?

  2. #2
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: stall between printing and closing

    try inserting a
    VB Code:
    1. DoEvents()
    after the printout line.
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  3. #3
    Fanatic Member Comintern's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln, NE
    Posts
    826

    Re: stall between printing and closing

    2 things. First, don't try to kill the document until after it has been closed. Second, you can use the BackgroundPrintingStatus property to see if Word has uncompleted print jobs:
    VB Code:
    1. ActiveDocument.PrintOut
    2.  
    3. Do Until Application.BackgroundPrintingStatus = 0
    4.     DoEvents
    5. Loop
    6.  
    7. ActiveDocument.Close False
    8. Application.Quit False
    9. Kill "temp.doc"

  4. #4
    Addicted Member
    Join Date
    Oct 2005
    Posts
    149

    Re: stall between printing and closing

    This last suggestion works, but there is a long (minute or more) delay before printing...

    Unless I put a break point at the DoEvents, then it seems to trigger an immediate print.

    Any suggestions how to trigger it immediately in code?

Posting Permissions

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



Click Here to Expand Forum to Full Width