How do I implement menu items with state?

A

Alex

How do I implement menu items with state in a Word add-in?

I am talking about something similar to the check-mark near the displayed toolbars or the square around the layout options on the "view" menu.
 
P

Peter Huang [MSFT]

Hi

If we just want to enable the Checked mark, we just need to set the State
to msoButtonDown. If we need a picture like the layout, we need also load
a picture.
Here is some VBA code for your reference.
Sub Test()
On Error Resume Next
Dim o As CommandBarButton
Set o = Application.CommandBars("View").Controls.Add(msoControlButton)
o.Caption = "Caption"
o.State = msoButtonDown
o.Picture = stdole.LoadPicture("c:\test.bmp")
End Sub

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
A

Alex

"Peter Huang" said:
Hi

If we just want to enable the Checked mark, we just need to set the State
to msoButtonDown. If we need a picture like the layout, we need also load
a picture.

Thank you Peter,

The State property was exactly what I needed.
I did not have to use a picture, since it displays a check-mark if there is no button face, or draws a border around the face if there is one.
 
P

Peter Huang [MSFT]

Hi

Thanks for your quickly reply!
If you still have any concern, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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