Discussion:
mouse events in MS Word 2007
(too old to reply)
PC Faris
2010-04-21 19:30:41 UTC
Permalink
Based on:
http://word.mvps.org/FAQs/MacrosVBA/

I tried to create a class module for oApp to handle events.
I get the oApp dropdown with then populates the VB editor with a list of
events, but they don't work.
I did this in the document itself and not in a template; and I run the
startoApp() manually instead of AutoExic, but this shouldn't matter, right?
So why doesn't it work?

See code (which I used in the class module) below.

Thanks,
Phil


Option Explicit
Dim oAppClass As New ThisApplication
Public WithEvents oApp As Word.Application

Public Sub startoApp()
Set oAppClass.oApp = Word.Application
End Sub

Private Sub oApp_WindowBeforeDoubleClick(ByVal Sel As Selection, Cancel As
Boolean)
MsgBox "crick crick"
End Sub
Klaus Linke
2010-04-29 16:18:49 UTC
Permalink
Post by PC Faris
http://word.mvps.org/FAQs/MacrosVBA/
Specifically,
http://word.mvps.org/FAQs/MacrosVBA/AppClassEvents.htm

Works fine for me...

Just to make sure what goes where:

Some code module:
Option Explicit
Dim oAppClass As New ThisApplication

Public Sub startoApp()
Set oAppClass.oApp = Word.Application
End Sub

Class module with name "ThisApplication":
Option Explicit
Public WithEvents oApp As Word.Application

Private Sub oApp_WindowBeforeDoubleClick(ByVal Sel As Selection, Cancel As
Boolean)
MsgBox "Just us crickets!"
End Sub


Regards,
Klaus

Loading...