tags:

views:

125

answers:

1

I have an SDI that I'm loading Excel into using OLE. I want to add a toolbar to this that I can use to have a very prominent and evident "import" button (and a few others). The toolbars I add through MFC are all hidden or otherwise removed from the interface when Excel becomes active. Is there a way to keep a toolbar up and on the interface when the Excel Ole item becomes active?

I've tried calling the FloatControlBar after the Excel OLE item is initialized, but it had no effect. I thought of twisting the menu (which does remain and behave normally) into a toolbar, but it would need to be docked on the left side (requirement) and have large, visible graphic depiction for the command ... and I haven't found a way to do that. CMenu class allows graphical menu items, but I haven't spotted a way to do much with the menu command itself (other than get its commandid in the message table).

A: 

Hi Steve

Although I'm not big on MFC, I have a bit of experience around interacting with Microsoft office apps via COM/OLE . I think if I understand you correctly, you are loading an excel document into your application and displaying in an OLE window? The Excel menus and buttons are then being displayed inside your app?

If this is the case, then by far the most straightforward way of adding a button to the toolbar is to add it into excel via a template that gets loaded on startup. This can contain your button and then run a small bit of VBA code that calls into your code. It may even be possible to call your menu item you have created via MFC.

One of the problems with automation via OLE , is that even though it is incredibly powerful, there are certain restrictions that seem to come into play once excel realises it is running in an ole window rather than natively. This may be preventing you from creating the buttons and showing them in your ole window.

Hope this is of some use.

Toby Allen
Thanks for your advice. I was hoping to make the button external to the Excel window portion, as that is a part of my interface requirements (handed to me). I can load my own menu, and use that (with no popup) as a toolbar, but it's not prominent enough.. easy to not see.
Steve