Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Actually, since the user presumably can delete the control or the
commandbar, the CommandBars.FindControl(... lines should be error-handled: On Error Resume Next CommandBars.FindControl(... On Error GoTo 0 In article , JE McGimpsey wrote: You can put this code in your add-in (assume the control is captioned "MyControl"): In the ThisWorkbook Module: Dim clsDimButton as New DimButtonClass Private Sub Workbook_Open() Set clsDimButton.DBApp = Application End Sub In a class module that you name DimButtonClass: Public WithEvents DBApp As Application Private Sub DBApp_WorkbookBeforeClose( _ ByVal Wb As Excel.Workbook, Cancel As Boolean) CommandBars.FindControl("MyControl").Enabled = _ (Workbooks.Count 1) End Sub Private Sub DBApp_WorkbookOpen(ByVal Wb As Excel.Workbook) CommandBars.FindControl("MyControl").Enabled = True End Sub In article , Beto wrote: Hi, I'd like to know how can I disable a button in my custom toolbar when there is no workbook open. Just like, for example, the print button is disabled when there is no workbook open. This toolbar is from an addin I'm developing. Thanks to anyone who can answer! Regards, |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Disable the save button | Excel Discussion (Misc queries) | |||
Disable X button on excel | Excel Worksheet Functions | |||
Disable Close Button | Excel Discussion (Misc queries) | |||
How do you disable the Collate button? | Excel Discussion (Misc queries) | |||
Disable Button | Excel Programming |