how to detect selection/focus in table cell of word document

A

AL

Would like to detect when a table cell is selected in Word document in order
to display message. Is there an available event that I can detect and
respond to?
 
H

Helmut Weber

Hi Al,

see
http://word.mvps.org/FAQs/MacrosVBA/AppClassEvents.htm

try a WindowSelectionChange event
and the following code:

Private Sub oApp_WindowSelectionChange(ByVal Sel As Selection)
If Selection.Information(wdWithInTable) Then
If Selection.Cells.Count = 1 Then
If Selection.Cells(1).Range = Selection.Range Then
MsgBox "Cell selected"
End If
End If
End If
End Sub
--

Greetings from Bavaria, Germany

Helmut Weber

Vista Small Business, Office XP
 
A

AL

wHelmut:
Thanks for the quick response. I think that detecting a window selection
change in a Word document is what I am looking for. Unfortunately, being a
bit of a novice, I was not able to get it to work. I suspect the problem is
more on my end than yours. I don't know if it makes any difference but I am
using Microsoft 2007. I'll keep trying though. Again, thank you.
 
A

AL

Helmut:
Greetings from Florida, USA
At first I was unsuccessful, but after sleeping on it and trying again this
morning, I got it to work. Thank you very much for your help.

AL
 

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