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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disabling buttons in button bar

Status
Not open for further replies.

hughesai

Technical User
Aug 1, 2002
101
GB
Hi all,

In Excel 2000 I have a number of VB routines linked to buttons on a custom button bar.
These are only relevant if a workbook is open and active.
I can add an error routine to these so that I don't get ugly errors occuring when I 'm using Excel.
How can I disable these buttons if no workbook is active e.g. in the same way that most of the standard format buttons are disabled, and only enabled when a workbook is opened.

Aidan.
 
Thanks DreamerZ.

I afraid that won't work. When I say a workbook, I mean any workbook. The functions I've got here are general ones, like a specific cell format that I use regularly, or a button to automatically add a standard header and footer to a sheet. I have added the buttons to the normal button bars.

I need the button bar and bars to be always visible, but certain buttons only enabled when there is an active sheet.

Hopefully that explains it a bit better.

Aidan.
 
Ah! Got it. Try this then:

Code:
If ActiveSheet.Name="Name of desired sheet" then

CommandBars(1).Controls(1).Enabled = False/True

End if

Put the code in the WorkBook_SheetActivate event where the "1" is the name of the Toolbar and name of the buttons (or index numbers).



DreamerZ
simplesoftware@prodigy.net
[ignore][/ignore]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top