Context menu in MS Word

Add-in Express™ Support Service
That's what is more important than anything else

Context menu in MS Word
 
Uwe


Guest


Hi, how can I dynamically add a menuitem and submenus to the context-menu in MS Word?

Something like
MyMenuItem
SubItem1
SubItem2
SubItem3
Posted 09 Mar, 2005 13:08:25 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Uwe,

It's easy to do. This context menu is a standard MS Word command bar named 'Text'. I have created an example for you:
http://www.add-in-express.com/projects/adx-word-context-menu.zip





Posted 10 Mar, 2005 06:40:09 Top
Uwe Thaden




Posts: 13
Joined: 2005-03-08
Thank!
Yes, I know that and I used your tool to get the IDs out of MS Word.

But I need to create the items dynamically at runtime.

And one more questions: Can you tell me if this works for all version of MS Word using adx?

Thanks,
Uwe
Posted 11 Mar, 2005 03:11:34 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Uwe,

But I need to create the items dynamically at runtime.

It is more complicated but I think this example will help you:
http://www.add-in-express.com/projects/adx-word-context-menu.zip

I have just updated it.

And one more questions: Can you tell me if this works for all version of MS Word using adx?


It should work for MS Word 2000, XP and 2003. Our experience shows that there is difference only between some Outlook versions.

Posted 11 Mar, 2005 06:50:31 Top
Guest


Guest


THANKS!
Posted 11 Mar, 2005 11:01:01 Top
Guest


Guest


Upps -- I'm too stupid: I tried to create a submenu based on your example using:

// popup
Popup := adxCommandBar2.Controls.Add(adxPopup, 'POPUP_TAG', 0, True).AsPopup;
Popup.Caption := 'GetContact';

// buttons
with Popup.Controls.Add(adxButton, 'BUTTON_TAG_1', 0, True).AsButton do begin
Caption := 'Uwes Button 1';
Style := adxMsoButtonCaption;
// OnClick := CommonButtonClick;
end;

Popup2 := Popup.Controls.Add(adxPopup, 'POPUP_TAG_2', 0, True).AsPopup;

with Popup2.Controls.Add(adxButton, 'BUTTON_TAG_2', 0, True).AsButton do begin
Caption := 'Uwes Button 2';
Style := adxMsoButtonCaption;
// OnClick := CommonButtonClick;
end;

But that does not work :-(

Any help?

Thanks,
Uwe
Posted 11 Mar, 2005 11:29:13 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Uwe,

Hmm... What exactly doesn't work?
Could you please send me your project?


Posted 11 Mar, 2005 11:54:13 Top
Guest


Guest


Here is the method (I put one adxCommandBar on the form):

procedure TAddInModule.adxCOMAddInModuleAddInStartupComplete(
Sender: TObject);
var
Popup: TadxCommandBarPopup;
Popup2: TadxCommandBarPopup;
begin
// Handle
Application.Handle := GetActiveWindow;

adxCommandBar2.Controls.Clear;
// popup
Popup := adxCommandBar2.Controls.Add(adxPopup, 'POPUP_TAG', 0, True).AsPopup;
Popup.Caption := 'GetContact';

// buttons
with Popup.Controls.Add(adxButton, 'BUTTON_TAG_1', 0, True).AsButton do begin
Caption := 'Uwes Button 1';
Style := adxMsoButtonCaption;
// OnClick := CommonButtonClick;
end;

Popup2 := Popup.Controls.Add(adxPopup, 'POPUP_TAG_2', 0, True).AsPopup;

with Popup2.Controls.Add(adxButton, 'BUTTON_TAG_2', 0, True).AsButton do begin
Caption := 'Uwes Button 2';
Style := adxMsoButtonCaption;
// OnClick := CommonButtonClick;
end;



// ShowMessage('Startup fertig');
end;

I thought it would be like:
GetContact
Button 1
Popup 2
Button 2

But there is no submenu from Popup 2 having the Button 2 a item.

Thanks,
Uwe
Posted 11 Mar, 2005 12:08:05 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Uwe,

It is later evening here and I am a little tired may be that is why looking at your code I don't see where the problem is.

I have just updated the example. Have a look and let me know about the results.
http://www.add-in-express.com/projects/word-context-menu.gif
http://www.add-in-express.com/projects/adx-word-context-menu.zip



Posted 11 Mar, 2005 12:42:05 Top
Uwe Thaden


Guest


Hi, it's 7:30 PM here, too ;-)

I just sent you an email with the result. I didn't change anything, but just compiled and ran. (I don't know how to attach a JPG here). It's quite different from the image you show.

It's MS Word 2002.

--Uwe
Posted 11 Mar, 2005 12:50:16 Top