Click Excel custom menu item via MFC automation

B

Bo Zhu

Hi,

I have a question regarding custom Excel 2003 menu item click via MFC
automation.

The VBA version of the action I want to do is pretty straightforward:
Application.CommandBars(1).Controls("NumeriX").Controls("Object
Tools").Controls("Delete All Objects").Execute

Now I need to translate the above line to C++ code. I already have the
automation classes for CCommandBars, CCommandBar0, CCommandBarControls,
CCommandBarControl classes generated by VS.NET 2003 class wizard.

The interesting thing is that the get_Item() method of CCommandBarControls
class returns a CCommandBarControl object, while in the VBA version another
CCommandBarControls object should be returned as the menu contains sub-menus.
Also I'm not so clear about the item index usage. From my preliminary
testing, the number returned by get_Count() method of CCommandBarControls
class is not equal to the number of visable menus on Excel menu bar.

Hope someone can clarify my doubt. Thanks!

Best regards,

Bo ZHU
 

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