Printing Pause will not Quit

O

Outatym

I have a pause set up in my code so that once Word has started printing, the
application will not close until the spooling is complete. During this, I
want to have a form show that tells users that their document is spooling and
will be printed shortly. I get the form to show, but Word will hang and not
hide the form or close the application. The VB editor still shows that it is
running even after the document is printed.....below is my code...am I
missing out on something?

********************************
Program Code that runs fine
********************************

PPSForm.Hide

Dialogs(wdDialogFilePrint).Show

PPSPrintForm.Show

ActiveDocument.PrintOut Background:=False

PPSPrintForm.Hide

Application.Quit

End Sub
 
G

Gordon Bentley-Mix

I suspect this is very similar to the problem discussed in one of my previous
posts (Code Hanging - Part II). If you read through this thread, you may find
the answer to your problem. A quick review of your code reinforces this
suspicion.

The short version of the answer is that when you hide a UserForm but do not
unload it and then show a built-in dialog, it creates a memory conflict
because you have two modal dialogs loaded at the same time. The problem is
not in the pause or in showing the second form but rather in simply hiding of
the first. Try unloading the first form (Unload PPSForm) before showing the
print dialog and see if this fixes the problem.

BTW, as Jean-Guy Marcil pointed out in my previous post, there's a lot to be
said for creating userform objects and explicitly referring to a specific
instance of a particular object rather than just working with the class name.
It requires a bit more thought at first but once you get your head around the
concept it becomes much easier.
--
Cheers!
Gordon
The Kiwi Koder

Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top