![]() |
Excel code to Wait until Word finishes printing before closing
I'm using Excel 2000 & windows nt 4, sp6.
I'm using Excel to extract label info to a 'prn' file, then opening a Word doc & merging 'prn' info, then printing the merged document. Works great - except that when I attempt to close the word object, I get a message that Word is printing & closing will stop the printing. Don't want that to happen, but I also want to close Word from within Excel. My question is: Is there a way to execute a loop to determine when the print job has finished? Where do I put the loop? Or this a needless worry? Thanks - mike Code: Dim wordApp As Object Set wordApp = CreateObject("Word.Application") With wordApp .Documents.Open Filename:="1.doc", _ (formatting code) .Application.PrintOut Filename:="1.doc", _ .activeDocument.Close End With wordApp.Quit |
Excel code to Wait until Word finishes printing before closing
Mike,
Put in a delay of 10 seconds to allow printing to finish before closing the doc. (You may find 5 seconds is long enough. Experiment!) Application.Wait Time + TimeValue("00:00:10") HTH Henry "Mike Molyneaux" wrote in message ... I'm using Excel 2000 & windows nt 4, sp6. I'm using Excel to extract label info to a 'prn' file, then opening a Word doc & merging 'prn' info, then printing the merged document. Works great - except that when I attempt to close the word object, I get a message that Word is printing & closing will stop the printing. Don't want that to happen, but I also want to close Word from within Excel. My question is: Is there a way to execute a loop to determine when the print job has finished? Where do I put the loop? Or this a needless worry? Thanks - mike Code: Dim wordApp As Object Set wordApp = CreateObject("Word.Application") With wordApp .Documents.Open Filename:="1.doc", _ (formatting code) .Application.PrintOut Filename:="1.doc", _ .activeDocument.Close End With wordApp.Quit |
All times are GMT +1. The time now is 06:59 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com