Problem with setting CommandBar.Visible property

J

James Wang

Hi,

I would like to control my add-in CommandBar programatically. But it
seems not to work properly.

I did some simple testing. Set CommandBar.Visible property to true in
WindowActivate event. I have two Word documents open and I mannually
turn off my add-in commandbar through View->ToolBar command for the
two documents. Then switch between the two documents. The commandbar
is supposed to show when the document is activated. For one document,
it works well, but it does not work for another one. I checked the
visible property of my commandbar, it's true. But I cannot see the
commandvar on the screen. Even through I close the document which does
not work and open another document instead, it 's still the same. It
has nothing to do with the document itself.
 
J

James Wang

I'm pretty sure that they are enabled and visible. This is a problem
with pure Word, I didn't try in Outlook.
 
K

Ken Slovak - [MVP - Outlook]

Check both properties. A toolbar has to be both to be visible in the UI.
 
J

James Wang

I found the problem.

I store the handle of my toolbar in a member variable. But when a new
document is opened, the handle stored in variable is invalid.
So I retrieve the handle of the toolbar everytime in the Activate
event and enable the toolbar, it works.

James
 

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