PDA

View Full Version : Returning current context menu in Word 2003



RustyCocoPat
03-18-2009, 04:52 AM
Hi. I am now certified insane after having tried to resolve this question for several weeks.

What I want to do is return the name of the current context menu as though I had right-clicked at the selection point. I know how to add menu items to builtin menus like this:

Set myControl = CommandBars("Text").Controls.Add(Type:=msoControlComboBox, Before:=1)
With myControl
.AddItem Text:="First Item", Index:=1
End With
End Sub

but that is not what I want to do as I am not adding a menu item.

I merely want to return the name of the context menu relevant to the selection point because of the rich information it provides about the place in the document (much better than range, story etc IMHO).

I have tried things like msgbox(CommandBars.Name) until the cows came home. No luck.

Thanks in anticipation.

fumei
03-20-2009, 09:49 AM
I merely want to return the name of the context menu relevant to the selection point because of the rich information it provides about the place in the document (much better than range, story etc IMHO).

AFAIK, it does not have a name because it is context sensitive. Say you right click when the Selection is on a field, you get Update Field, Toggle Field Codes etc; if the Selection is on a hyperlink, you get hyperlink stuff, in a blank spot in table, you get table stuff. You know this.

So no, it is not a different name when it is showing the items for being in a table, a different name when it is on a field etc. etc.

It is all the same menu...but context sensitive.

I am VERY curious as to what information you are wanting to get. Could you elaborate?

RustyCocoPat
03-20-2009, 06:46 PM
Thanks fumei.

What I am looking for is the rich context sensitive information represented by the builtin menus that are listed if you right-click the menu bar and click Customize, Shortcut Menus.

I know that some or all of this info is available via various other methods but it would be simpler if I could get it via the shortcut menus.

RustyCocoPat
03-21-2009, 04:19 PM
Actually, I now realise that I didn't express my requirement very well.

What I want to do is return the name of the current context menu that the user has clicked or could click.

Thanks.

macropod
03-22-2009, 11:54 PM
Hi Jarosite/RustyCocoPat,

It's rude to post the same question in numersous forums without mentioning this fact. So far, you've posted the same question in:
http://www.tek-tips.com/viewthread.cfm?qid=1538154&page=1
http://www.vbaexpress.com/forum/showthread.php?t=25750
and
http://www.wopr.com/index.php?showtopic=761690
without acknowledging in any of them the advice you've been given in the others.

RustyCocoPat
03-23-2009, 02:15 AM
My apologies. I wasn't aware of the convention and didn't mean to cause offence. I simply perceived that some people did not have the answer I was seeking and thought that others might.

Consider the matter closed.