Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2006

Tip: Looking for answers? Try searching our database.

How do you know when printing has finished?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Henry - 03 Feb 2006 20:05 GMT
Word 2K running under WinXP.

I've got a command button on my Doc. with the code behind it as:

Me.Printout

Me.SaveAs ("filename") etc.

Application.Quit

The problem is that I'm printing to a network printer and the network can be
very slow at times.
It's only one page long, but I often get a messagebox popping up saying that
the printing hasn't finished and closing down word will cancel the print
job.
I've tried putting DoEvents at various places in the code and tried to use
Application.Wait (a valid Excel VBA command, but not valid in Word VBA) to
force a pause, all to no avail.

Any of you Word VBA gurus got an answer to this one?

TIA

Henry
Jay Freedman - 03 Feb 2006 20:16 GMT
> Word 2K running under WinXP.
>
[quoted text clipped - 20 lines]
>
> Henry

Change the .Printout line to

   Me.PrintOut Background:=False

When you omit the optional Background parameter, its default value of True
means that Word should create a "background process" to send the document to
the print spooler, and immediately return control to the macro. By making it
False, you're saying to use the "foreground process"; that makes the macro
wait until the spooling is completed before executing the next line of the
macro.

Signature

Regards,
Jay Freedman
Microsoft Word MVP          FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

Helmut Weber - 03 Feb 2006 20:21 GMT
Hi Henry,

see help for: "application.backgroundprintingstatus", hopefully.

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

Henry - 03 Feb 2006 23:47 GMT
Thanks Jay & Helmut

I'll try that on Monday, when I get to work.

Henry

> Hi Henry,
>
> see help for: "application.backgroundprintingstatus", hopefully.
Alex Ivanov - 05 Feb 2006 06:59 GMT
Keep in mind that checking Backgroundprintingstatus in some (rare) cases
causes infinite loop.
It never changes to 0, and may produce no printouts until you press
ctrl-break.
Neither doevents nor Sleep inside the loop helps, if this happens.
Signature

Please reply to NG only. This email is not monitored.
Alex.

> Thanks Jay & Helmut
>
[quoted text clipped - 5 lines]
>>
>> see help for: "application.backgroundprintingstatus", hopefully.
Jonathan West - 06 Feb 2006 11:01 GMT
> Thanks Jay & Helmut
>
> I'll try that on Monday, when I get to work.

You should take a look at this article

How to find out whether Word has finished printing
http://www.word.mvps.org/FAQs/MacrosVBA/WaitForPrint.htm

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org 

Henry - 10 Feb 2006 00:33 GMT
>> Thanks Jay & Helmut
>>
[quoted text clipped - 4 lines]
> How to find out whether Word has finished printing
> http://www.word.mvps.org/FAQs/MacrosVBA/WaitForPrint.htm

Thanks all,

Jay's solution works just fine, thank you Jay.

I'll bear in mind Alex's warning, but it doesn't seem to be a problem ATM.

I went to your link, Jonathan, but it seems to say that 'Background:=False'
is the preferred way to do it.

Once again, thanks all.

Henry
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.