WORD VBA help needed - problem with events handler

EllieCat

New Member
Joined
May 9, 2007
Messages
44
I'm writing a macro in word, which is an adjustment to the Normal.dot, adding an extra stage to the print events handler to prevent certain documents from being printed on unsecured printers.

Inside the ThisDocument Object is the following code:

Code:
 Dim X As New EventClassModule

Private Sub Document_New()
    Set X.App = Word.Application
End Sub

Private Sub Document_Open()
    Set X.App = Word.Application
End Sub

This correctly initialises the Events module if you open Word from a saved document, but doesn't initialise if I open Word from the start menu until I create a new document2.

i.e.

I open Word from the start menu, which opens a new Document1 by default, the events handler doesn't trigger.

I open another new document, Document2, which initialises the events handler, it then works perfectly from here.

Does anyone know how to force initialisation on the first opening? It has to be automatic, not a user initiated step.

On a related note, does anyone know how to apply these changes to multiple copies of Word without overwriting the normal.dot file, or copying the macro into every normal.dot?

Thanks!

EllieCat
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Forum statistics

Threads
1,222,032
Messages
6,163,509
Members
451,839
Latest member
HonestZed

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top