Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default Disabling Toolbar Buttons with no open Workbook

Hi all

I have 2 issues:
================================================== ==========================
### 1 ###
I have added some custom buttons with some custom code to the Standard
toolbar in XL-xp and they work fine, and I want them to 'gray-out'
when there's no workbook open (just like built-in buttons).

I tried adding some code to the Workbook_Open, Workbook_New and
Workbook_Close events of Personal.xls as follows:

If Workbooks.Count <= 2 Then
CommandBars("Standard").Controls("Custom").Enabled = False
Else
CommandBars("Standard").Controls("Custom").Enabled = True
End If

Though I have similar code working fine in Word, this code does not
execute when I open a workbook. Any suggestions appreciated.

================================================== ==========================
### 2 ###
With the above buttons, I am using toggle buttons from the Control
Toolbox. Although the code executes fine, the buttons do not
alternate between the usual 'toggle-on' and 'toggle-off' styles. Any
suggestions on how to achieve this?

Thanks in advance

Paul Martin
Melbourne, Australia
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Disabling Toolbar Buttons with no open Workbook

I never try to disable the buttons but you can try this code

Sub test()
On Error GoTo closesub
ActiveWorkbook.Activate

' your code


closesub:
MsgBox "There is no file open"
Exit Sub
End Sub

2??

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Paul Martin" wrote in message om...
Hi all

I have 2 issues:
================================================== ==========================
### 1 ###
I have added some custom buttons with some custom code to the Standard
toolbar in XL-xp and they work fine, and I want them to 'gray-out'
when there's no workbook open (just like built-in buttons).

I tried adding some code to the Workbook_Open, Workbook_New and
Workbook_Close events of Personal.xls as follows:

If Workbooks.Count <= 2 Then
CommandBars("Standard").Controls("Custom").Enabled = False
Else
CommandBars("Standard").Controls("Custom").Enabled = True
End If

Though I have similar code working fine in Word, this code does not
execute when I open a workbook. Any suggestions appreciated.

================================================== ==========================
### 2 ###
With the above buttons, I am using toggle buttons from the Control
Toolbox. Although the code executes fine, the buttons do not
alternate between the usual 'toggle-on' and 'toggle-off' styles. Any
suggestions on how to achieve this?

Thanks in advance

Paul Martin
Melbourne, Australia



Reply
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
Delete Web Toolbar when Open A Hyperlink workbook T_Yuri[_2_] Excel Discussion (Misc queries) 4 August 5th 08 01:06 PM
Disabling Minimise/Restore Down buttons Scampa7[_2_] Excel Programming 1 October 25th 03 07:05 PM
Disabling Toolbar buttons and CommandBar items Jim[_20_] Excel Programming 2 August 14th 03 02:33 PM
Disabling toolbar customization kb Excel Programming 0 July 29th 03 08:33 PM
Option buttons - disabling Ann Excel Programming 1 July 23rd 03 01:04 AM


All times are GMT +1. The time now is 03:00 AM.

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

About Us

"It's about Microsoft Excel"