LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Disable Button when no workbooks are open.

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Disable the save button leerem Excel Discussion (Misc queries) 4 December 10th 08 01:06 PM
Disable X button on excel pano Excel Worksheet Functions 6 March 28th 07 02:15 AM
Disable Close Button dan Excel Discussion (Misc queries) 5 September 22nd 06 07:39 PM
How do you disable the Collate button? Trixie Excel Discussion (Misc queries) 0 August 25th 06 04:00 PM
Disable Button Pete[_12_] Excel Programming 3 October 8th 03 01:30 PM


All times are GMT +1. The time now is 08:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"