can anyone tell me if in word 2000 is there Before_Print event available as I cant seem to find one?
Cheers
Gibbo
can anyone tell me if in word 2000 is there Before_Print event available as I cant seem to find one?
Cheers
Gibbo
Hi Gibbo. I'm sorry but my version is 2002. Try to type "Documentbeforeprint" in the VBE guide.
Bye
Hi ALe
Thanks for the reply
my help said the following should work for me
But doesnt seem to do anything for me, any ideas what im missing herePrivate Sub App_DocumentBeforePrint(ByVal Doc As Document, Cancel As Boolean) a = MsgBox("Have you checked the " _ & "printer for letterhead?", _ vbYesNo) If a = vbNo Then Cancel = True End Sub
Last edited by Aussiebear; 03-26-2023 at 01:22 AM. Reason: Adjusted the code tags
Have you put it in a class module with the declaration "Public WithEvents appWord as Word.Application" at the top?
Yes
Have class1 Class Module as below
[VBA] Public WithEvents appWord As Word.Application
Private Sub App_DocumentBeforePrint(ByVal Doc As Document, Cancel As Boolean)
a = MsgBox("Have you checked the " _
& "printer for letterhead?", _
vbYesNo)
If a = vbNo Then Cancel = True
End Sub [/VBA]
cheers
gibbo
have you a standard module where you make a new istance?
No nothing in a standard module at the moment?
Put this in a standard module and run the procedure "Register_Event_Handler"
Be sure that your class module is named EventClassModuleOption Explicit Dim X As New EventClassModule Sub Register_Event_Handler() Set X.appWord = Word.Application End Sub
Last edited by Aussiebear; 03-26-2023 at 01:23 AM. Reason: Adjusted the code tags
Tried as above but still doesnt work for me?
Module1
EventClassModuleOption Explicit Dim X As New EventClassModule Sub Register_Event_Handler() Set X.appWord = Word.Application End Sub
CheersPublic WithEvents appWord As Word.Application Private Sub App_DocumentBeforePrint(ByVal Doc As Document, Cancel As Boolean) a = MsgBox("Have you checked the " _ & "printer for letterhead?", _ vbYesNo) If a = vbNo Then Cancel = True End Sub
Gibbo
Last edited by Aussiebear; 03-26-2023 at 01:23 AM. Reason: Adjusted the code tags
what does it say as error?
Doesnt error, just doesnt give me my messagebox before printing
Just tried playing with it a bit, if i ask it just to display a message nothing happens, if I have my original code it does print but no message, very strange
It should work. Try to run the proc register event handler and immediately after click the print button.
Nope didnt work for some reason
I ve ammeded my code to just display a message box, it shows in the status bar it is printing but doesnt actually print and doesnt show the message box,
also tried writing to a bookmark before print, that didnt work either.
Also tried calling another sub again no joy
Very confusing
I'll send my file. Check it if it works alone so we understand if the problem is your word version or your own code.
As you can see the proc is called when the document is opened
thanks ALe, i cant check it until this evening as i dont have winzip at work but will try it then and get back to you
Thanks for your help
Gibbo
Ok. We'll get in contact. Bye
Try puting this in the ThisDocument module (tested in Word 2000):
Marcster.Sub FilePrint() 'Runs when user selects Print from the File menu Call AskMsg End Sub Sub FilePrintDefault() 'Runs when user clicks on the printer toolbar button Call AskMsg End Sub Sub AskMsg() Select Case MsgBox("Have you checked the printer for letterhead?", vbYesNo Or vbQuestion Or vbDefaultButton1, "Info") Case vbYes MsgBox "Ok you can now print" Dialogs(wdDialogFilePrint).Show Case vbNo Exit Sub End Select End Sub
Last edited by Aussiebear; 03-26-2023 at 01:24 AM. Reason: Adjusted the code tags
Thanks Marcster That worked great
Gibbo