Detect Right-Click (Shortcut Menu)

A

Alan

I added a command button to the right-click (a.k.a. shortcut or pop-
up) menu in Word. However, I need to be able to enable or disable it
based on whether or not text in the document is selected (I know how
to detect it).

My question: How do I determine this before the shortcut menu
appears?

Thanks, Alan
 
S

Shasur

You can try that with Word Application's "WindowBeforeRightClick" event

Public WithEvents appWord As Word.Application

Private Sub appWord_WindowBeforeRightClick(ByVal Sel As Selection, Cancel As
Boolean)
If Len(Sel.Range) <> 0 Then
' your condition
End If
End Sub
--

You need to insert the above procedure in the class module and initialize
the application object appWord.

Dim oWA As New Class1

Sub Init_Word_Object()

Set oWA.appWord = Word.Application
End Sub


http://vbadud.blogspot.com

Cheers
Shasur
 

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