Application Events

M

Mike Bassett

I am attempting to use the
Application.DocumentBeforePrint event to trigger a
UserForm. I have a class containing the required code to
open the userform on condition that various formfields
have not been filled in, and the class is registered on
opening the document. All works well but only once. If I
launch the print task then the form opens, I then cancel
the print and launch print again but the form doesn't
open, I have to run the registration manually or close
and re-open the document before it will work again. What
can I do to overcome this problem?

Also I would like to know if it is possible to cancel the
print from the event procedure as I do not want the user
to be able to print if the fields are not filled in.
 
W

Word Heretic

G'day "Mike Bassett" <[email protected]>,

Without code samples, its just pure guesswork. Are you using magic
forms? Don't.

Ie

Bad:

frmUserForm1.show

Good

Dim MyForm as frmUserForm1

Set MyForm = new frmUserForm1
MyForm.Show
Set MyForm=Nothing


Steve Hudson - Word Heretic
Want a hyperlinked index? S/W R&D? See WordHeretic.com

steve from wordheretic.com (Email replies require payment)


Mike Bassett reckoned:
 
S

Steve Lang

Hi Mike,

Just a thought, but why use an application event? Hijack the FilePrint
macro. Put your code in and if all is good, display the regular print
dialog. If not, exit the sub and the user cannot print. Using the
application event is probably adding more complexity - and opportunity for
error - than required.

Sub FilePrint
'your code here
If isGood Then Dialogs(wdDialogFilePrint).Show
End Sub


HTH and have a great day!

Steve
 

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