How to refer to a menu button not using its caption.

D

damezumari

I have code that puts a button on the Tools menu:

CustomizationContext = ActiveDocument.AttachedTemplate

With CommandBars("Menu Bar").Controls("Tools").Controls
Set mybutton = .Add(Type:=msoControlButton)
'mybutton.BeginGroup = True ' gives a separator above the button
mybutton.FaceId = 990 ' 2174 ' 7391
mybutton.Caption = "AutoFooter is On"
mybutton.OnAction = "MacroOn"
mybutton.Visible = True
End With

To display the caption I can use:

CommandBars("Menu Bar").Controls("Tools").Controls("AutoFooter is
On").Caption

But, if I want the user to be able to toggle the caption to "AutoFooter
is Off", how can I then test which caption it has?

I use Word 2003 and Win2000.

Regards,

Jan Nordgreen
 
K

Klaus Linke

Hi Jan,

Use CommandBars.ActionControl.Caption in your macro "MacroOn".

Greetings,
Klaus
 
D

damezumari

Thanks!

That worked.

Last question:

Sub MacroOn()
If CommandBars.ActionControl.Caption = "AutoFooter is On" Then
CommandBars.ActionControl.Caption = "AutoFooter is Off"
' FaceId = 0
Else
CommandBars.ActionControl.Caption = "AutoFooter is On"
' FaceId = 423
End If
End Sub

How do I change the FaceId in the code above? The commented line is
obviously not enough? :)

Regards,

Jan Nordgreen
 

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