word pop menu

S

sarah

i am trying to add a popup menu to word where if a word is underlined it will
have an extra menu item when it is right-clicked. However if another word is
right-clicked that is not underlined then i do not want the menu item to be
on the popup menu

Here is my code

<code>
Dim ShortCutMenu As CommandBar
Dim Menu As CommandBarPopup
Dim ctrl As CommandBarControl

If Selection.Font.Underline = wdUnderlineWavy Then

With Selection
.Expand wdWord ' Select insertion point word.
' Deselect any trailing spaces.
Do While Right(.Text, 1) = Chr(32)
.MoveLeft Unit:=wdCharacter, _
Count:=1, Extend:=wdExtend
Loop
selWord$ = Trim(.Text) ' Store selection.

MsgBox selWord$

Set ShortCutMenu = CommandBars("text")
Set Menu = ShortCutMenu.Controls.Add(Type:=msoControlPopup,
temporary:=True)

With Menu
.BeginGroup = True
.Caption = "&MenuItem"
' .OnAction = "AccessThesaurusMenu"
End With

System.Cursor = wdCursorWait

Set Menu = CommandBars.ActionControl

End With
Else

Menu.Delete(false)

End If
</code>

This does not work.

If it does add the menu item, it cannot be deletedAny help would be much
appreciated
 

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