Controlling menus of hosted MS-Word

A

Alex

Hello people,

I can easily manipulate the MS-Word menu items using Application.CommandBars.ActiveMenuBar.Controls.
It works without problems both from COM add-ins and VBA macros.

However, if the Word window is hosted in another application it no longer works.

Try it yourself:

1) Open a Word document in Internet Explorer

2) display Application.CommandBars.ActiveMenuBar.Controls(1).Caption
You get "&File", which is the first menu item.

3) Application.CommandBars.ActiveMenuBar.Controls(1).Delete
Notice that the menu in IE did not change.

4) Sanity check: display Application.CommandBars.ActiveMenuBar.Controls(1).Caption again
Now it is "&Edit", the 2nd menu item.

So Word thinks that the menu item has been deleted but IE does not know anything about it!

Same problem trying to add, enable/disable or show/hide menu items.
No effect. Zilch. Nada.


Here's what I am trying to do:

I have a Word add-in written in C# that inserts its own menus.
Some times I need to disable (or hide) them based on the current state of the document.

Unfortunately, if the Word window is hosted in another application (IE, DsoFramer, you name it) it does not work.

Any help is appreciated!


Thanks,
Alex.
 
A

Alex

Hello Peter,

Peter Huang" said:
Based on my experience, the principle is similar.
When we are hosting Word(or other Office Application), generally it is a
ActiveX Document technology, in IE, DSOFramer or other ActiveX Document
Container.
The rule is that the IE(e.g.) will contact the ActiveX Document
Server(Word) to show the UI inside the IE client area, so the UI is just as
we see in the Word, because it is Word's job to show that. But for the
Menu(I mean it is the ToolBar) will be merged into the IE Menu, so you will
find that the Style will be similar with IE's menu, because we can almost
consider them as IE's menu, and the IE's Menu will delegate the menu call
to Word Process to handle the Word related command.

That's is why the Word Object Modal which used to handle commandbar will
not work with IE merged menu any more.

However, the Word menus inside IE (and other container programs) *will* change their enabled/disabled state.

For example, if the selection is inside a table, table-related menu items will be enabled. Otherwise, they will became disabled.

How can I duplicate this functionality in hosted Word for menus that I created in my add-in?


Best wishes,
Alex.
 

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