Mac Office 2004 - WindowSelectionChange event handler

  • Thread starter Mac Office Developer
  • Start date
M

Mac Office Developer

Does anyone have an idea on how to attach to the WindowSelectionChange event
handler on a mac? It works find on the PC, but Mac doesn't show this as an
event on the Word.Application object...
 
J

John McGhie

As far as I know, NO released version of Mac Word supports ANY events. They
may be supported in Word 2010 for Mac, but we don't know yet.

Sorry


Does anyone have an idea on how to attach to the WindowSelectionChange event
handler on a mac? It works find on the PC, but Mac doesn't show this as an
event on the Word.Application object...

--

The email below is my business email -- Please do not email me about forum
matters unless I ask you to; or unless you intend to pay!

John McGhie, Microsoft MVP (Word, Mac Word), Consultant Technical Writer,
McGhie Information Engineering Pty Ltd
Sydney, Australia. | Ph: +61 (0)4 1209 1410
+61 4 1209 1410, mailto:[email protected]
 
M

Mac Office Developer

I know for sure the following events are supported, and work correctly

Document.Close
Document.New
Document.Open

Application.DocumentChange
Application.Quit

There "must" be some tricky VBA way to intercept the WindowSelectionChange,
right???

BTW: We are using v2004, which is fine for our needs
 
J

Jim Gordon Mac MVP

Mac said:
Does anyone have an idea on how to attach to the WindowSelectionChange event
handler on a mac? It works find on the PC, but Mac doesn't show this as an
event on the Word.Application object...

WindowSelectionChange is not available on the Mac. The Click event is
available. Would it help if you wait till the user clicks and then
determine the activewindow?

-Jim
 
M

Mac Office Developer

that is a good start.

how do we intercept the click event? we tried both the Document and
Application objects, but neither seem to fire the click event to fire on
those...

BTW: we are using Mac Office 2004
 
J

Jim Gordon Mac MVP

Mac said:
that is a good start.

how do we intercept the click event? we tried both the Document and
Application objects, but neither seem to fire the click event to fire on
those...

BTW: we are using Mac Office 2004

I see. The click event works with UserForms. This code works for a
userform that has a button on it named MyButton. It's slightly modified
from the VBA Help examples.

When you run the form and click somewhere else besides the button, the
form changes size. If you click on the button, the caption on the button
changes. Frustratingly, the accelerator key doesn't work. I put the
following code on the Userform module:

Option Explicit
Public tag


Private Sub MyButton_Click()
If MyButton.Caption = "OK" Then 'Check caption, then change it.
MyButton.Caption = "Clicked"
MyButton.Accelerator = "C" 'Set Accelerator key to
COMMAND + C
Else
MyButton.Caption = "OK"
MyButton.Accelerator = "O" 'Set Accelerator key to
COMMAND + O
End If
End Sub

' Activate event for UserForm1
Private Sub UserForm_Activate()

UserForm1.Caption = "Click me to make me taller!"
Let tag = UserForm1.Height ' Save the initial height.
MsgBox tag
End Sub

' Click event for UserForm1
Private Sub UserForm_Click()
Dim NewHeight As Single
NewHeight = Height
' If the form is small, make it tall.
If NewHeight = Val(tag) Then
Height = Val(tag) * 2
Else
' If the form is tall, make it small.
Height = Val(tag)
End If
End Sub

' Resize event for UserForm1
Private Sub UserForm_Resize()
UserForm1.Caption = "New Height: " & Height & " " & "Click to
resize me!"
End Sub



If you poke around the Help system in the visual basic editor you'll
find more events that work with UserForms

Help topic: UserForm Object, UserForms Collection - Events
AddControl Event
BeforeDragOver Event
BeforeDropOrPaste Event
Click Event
DblClick Event
Error Event
KeyDown, KeyUp Events
KeyPress Event
Layout Event
MouseDown, MouseUp Events
MouseMove Event
RemoveControl Event
Scroll Event
Zoom Event
Activate, Deactivate Events
Terminate Event (Visual Basic for Applications)

So what I want to know is if you are using userforms or whether your are
trying to detect events as they occur as a user is working in a Word
document rather than a userform? The events that work for Word documents
rather than userforms are the ones you mentioned earlier:
Document.Close
Document.New
Document.Open
Application.DocumentChange
Application.Quit

I'm not sure exactly what you're trying to do. Excel and PowerPoint have
their own object models and offer different event handling options.
Excel has an event handler that can be initiated by changes made on a
worksheet. See the SheetChange Event in Excel's VBA Help for an example.

Maybe something I've said here will be of assistance.

-Jim
 
M

Mac Office Developer

yes, we are looking to intercept the events while the user is editing the
word document... not while a userform is displayed...

for example, if the user clicks in the cell of a table, we will inspect the
contents of that cell to determine certain things. the way that we accomplish
on the PC is to attach to the Application.WindowSelectionChange event
handler, and use the selection object to determine if the user is in a table
cell...

we are porting this for our Mac Office users, and trying to provide as much
functionality as possible... intercepting when the user has changed where
they are in the document is a necessity...

do we need to build an add-in rather than us VBA? If so, where do we start?

thanks!
 
J

John McGhie

Yes: Now you see why I said "VBA has "no events" on the Mac. You would
need to create your own event trap the way Microsoft has for the ones that
it supports.

While we think that you "can" develop add-ins for Mac Office, we have so far
been unable to get any details or documentation from Microsoft to say how to
do that.

The old methods you will see documented around the Internet do not work.

If you send me an email (address in the .sig) I will put you in touch with
the Microsoft engineer who organisers partner associations for Developers.
Once you are approved and sign all the NDAs, then they will tell you how it
all works.

Or: You could wait six months. The next version of PC Office has been
announced to ship in June 2010. The equivalent version of Mac Office will
follow sometime later (maybe before the end of 2010).

Cheers

yes, we are looking to intercept the events while the user is editing the
word document... not while a userform is displayed...

for example, if the user clicks in the cell of a table, we will inspect the
contents of that cell to determine certain things. the way that we accomplish
on the PC is to attach to the Application.WindowSelectionChange event
handler, and use the selection object to determine if the user is in a table
cell...

we are porting this for our Mac Office users, and trying to provide as much
functionality as possible... intercepting when the user has changed where
they are in the document is a necessity...

do we need to build an add-in rather than us VBA? If so, where do we start?

thanks!

--

The email below is my business email -- Please do not email me about forum
matters unless I ask you to; or unless you intend to pay!

John McGhie, Microsoft MVP (Word, Mac Word), Consultant Technical Writer,
McGhie Information Engineering Pty Ltd
Sydney, Australia. | Ph: +61 (0)4 1209 1410
+61 4 1209 1410, mailto:[email protected]
 

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