Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to make a toolbar button visible?

Status
Not open for further replies.

hstijnen

Programmer
Nov 13, 2002
172
NL
Hi,
I've hidden a toolbar button manually (Word 2000). Now I want to make it visible with VBA.
I have already som code:
For Each ctl In CommandBars("formatting").Controls
If ctl.caption = strCaption Then
ctl.visible = visible
End If
Next ctl

But it appears the looping is only through visible buttons, so my invisible button is not found.
What can I do?

Thanks for help,

Henk
 
You say :

I've hidden a toolbar button manually

How did you do that, exactly? Did you actually remove the button from the toolbar ( in which case it isn't just invisible, is it! )?

Have you tried reversing your actions with Macro Recorder on, and looking at what is recorded?

Cheers, Glenn.

Did you hear about the literalist show-jumper? He broke his nose jumping against the clock.
 
I've clicked the button "More buttons" at the end of the toolbar. This gives a checkbox list of the buttons in the toolbar. Here I've unchecked the button.
When I record the reverse action, there is no code in the macro.
 
Using macro record and removing and restoring the "Align Right" toolbar button resulted in this code:

Code:
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 24/08/05 by Glennuk
'
    CommandBars("Formatting").Controls(9).Delete
End Sub
Sub Macro2()
'
' Macro2 Macro
' Macro recorded 24/08/05 by Glennuk
'
    CommandBars("Formatting").Controls.Add Type:=msoControlButton, ID:=121 _
        , Before:=10
End Sub

Cheers, Glenn.

Did you hear about the literalist show-jumper? He broke his nose jumping against the clock.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top