Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / August 2005

Tip: Looking for answers? Try searching our database.

How to make toolbar button visible?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
hstijnen - 24 Aug 2005 14:02 GMT
Hi,
I've hidden a toolbar button manually. 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
Klaus Linke - 24 Aug 2005 14:49 GMT
Hi Henk,

          ctl.visible = True

Better use Option Explicit at the top of the module to avoid such typos.

Greetings,
Klaus

> Hi,
> I've hidden a toolbar button manually. Now I want to make it visible with
[quoted text clipped - 14 lines]
>
> Henk
hstijnen - 24 Aug 2005 15:06 GMT
I'm sorry, Klaus,
That's not the problem. "visible" is a parameter of a function, wherewith I
wuold like to mke the button visible or invisible. The full code is:

Sub SetButtonVisible(caption As String, visible As Boolean)
   For Each ctl In CommandBars("formatting").Controls
       If ctl.caption = caption Then
          ctl.visible = visible
       End If
   Next ctl
End Sub

The sub works ok for setting a button invisible. But when resetting visible
the button appears not in the collection
For Each ctl In CommandBars("formatting").Controls
So the question is how to get the invisible buttons in the collection.

Greetings,
Henk

> Hi Henk,
>
[quoted text clipped - 23 lines]
> >
> > Henk
Klaus Linke - 24 Aug 2005 15:35 GMT
> So the question is how to get the invisible buttons in the collection.

Shouldn't make a difference whether they are visible or not.
Perhaps single-step, or try to put a
Debug.Print ctl.caption
in the loop to see if all controls are looped?
Or check CommandBars("Formatting").Controls.Count?

Regards,
Klaus

> I'm sorry, Klaus,
> That's not the problem. "visible" is a parameter of a function, wherewith
[quoted text clipped - 46 lines]
>> >
>> > Henk

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.