Is this a Word 2003 VBA bug? DocumentBeforePrint executes multiple times?
I reference
http://msdn.microsoft.com/en-us/library/office/aa211873(v=office.11).aspx
http://msdn.microsoft.com/en-us/library/office/aa211915(v=office.11).aspx
I make a test.dot with macro DocumentBeforePrint.
'ref http://msdn.microsoft.com/en-us/library/office/aa211915(v=office.11).aspx
Dim X As New EventClassModule
Sub Register_Event_Handler()
Set X.appWord = Word.Application
End Sub
Private Sub Document_New()
Call Register_Event_Handler
End Sub
Private Sub Document_Open()
Call Register_Event_Handler
End Sub
'ref http://msdn.microsoft.com/en-us/library/office/aa211873(v=office.11).aspx
Public WithEvents appWord As Word.Application
Private Sub appWord_DocumentBeforePrint _
(ByVal Doc As Document, _
Cancel As Boolean)
MsgBox "WORKING!"
End Sub
When I press Ctrl+P, the macro executes.
There is a bug. When I double click test.dot to generate two word files (a.doc/b.doc).
Press Ctrl+P,the DocumentBeforePrint will execute twice.
If I generate 3 word files, Press Ctrl+P, the Macro will execute three times.
What's wrong? I just want to execude once.