Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Search Existing Toolbars

When a workbook is opened, is there any way to search all available toolbars
for the existence of a particular button (i.e., customized buttons a user may
have added in another workbook, such as Advanced Filter...) and if found,
disable it? Thanks.
--
Steve C
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Search Existing Toolbars

Hi Steve

such as Advanced Filter


http://www.rondebruin.nl/menuid.htm

Sub MenuControl_False()
' Excel 2000 - 2003
Dim Ctrl As Office.CommandBarControl
For Each Ctrl In Application.CommandBars.FindControls(ID:=901)
Ctrl.Enabled = False
Next Ctrl
End Sub

Sub MenuControl_True()
' Excel 2000 - 2003
Dim Ctrl As Office.CommandBarControl
For Each Ctrl In Application.CommandBars.FindControls(ID:=901)
Ctrl.Enabled = True
Next Ctrl
End Sub




--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Steve C" wrote in message ...
When a workbook is opened, is there any way to search all available toolbars
for the existence of a particular button (i.e., customized buttons a user may
have added in another workbook, such as Advanced Filter...) and if found,
disable it? Thanks.
--
Steve C

  #3   Report Post  
Posted to microsoft.public.excel.programming
Jay Jay is offline
external usenet poster
 
Posts: 671
Default Search Existing Toolbars

Hi Steve -

Sub SteveC()
For Each cmdBar In Application.CommandBars
For Each ctrl cmdBar.Controls
If ctrl.Caption = "&Advanced Filter..." Then 'Adjust name to suite*
With ctrl
.Visible = True 'True or False to suit
.Enabled = False 'True or False to suit
End With
End If
Next 'ctrl
Next 'cmdBar
End Sub

*Footnote: To find the exact name of the control (button) you're interested
in, rightclick in any toolbar, select 'Customize...' and then rightclick the
button to see its Name property.

Reminder: Any change you make with the above code is completely reversible,
but is 'permanent' until explicitly reversed by the above code (change false
to true or vice versa) or by some other existing code. The modified toolbar
is saved when excel closes.
--
Jay


"Steve C" wrote:

When a workbook is opened, is there any way to search all available toolbars
for the existence of a particular button (i.e., customized buttons a user may
have added in another workbook, such as Advanced Filter...) and if found,
disable it? Thanks.
--
Steve C

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Search Existing Toolbars

Hi Jay

See my reply that use the ID together with findcontrol.
Working in other languages also then

--
Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Jay" wrote in message ...
Hi Steve -

Sub SteveC()
For Each cmdBar In Application.CommandBars
For Each ctrl cmdBar.Controls
If ctrl.Caption = "&Advanced Filter..." Then 'Adjust name to suite*
With ctrl
.Visible = True 'True or False to suit
.Enabled = False 'True or False to suit
End With
End If
Next 'ctrl
Next 'cmdBar
End Sub

*Footnote: To find the exact name of the control (button) you're interested
in, rightclick in any toolbar, select 'Customize...' and then rightclick the
button to see its Name property.

Reminder: Any change you make with the above code is completely reversible,
but is 'permanent' until explicitly reversed by the above code (change false
to true or vice versa) or by some other existing code. The modified toolbar
is saved when excel closes.
--
Jay


"Steve C" wrote:

When a workbook is opened, is there any way to search all available toolbars
for the existence of a particular button (i.e., customized buttons a user may
have added in another workbook, such as Advanced Filter...) and if found,
disable it? Thanks.
--
Steve C

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Search Existing Toolbars

Excellent, Ron. Thanks a ton! Where could I get a list of control ID
numbers (i.e., ID=901) and their descriptions?
--
Steve C


"Ron de Bruin" wrote:

Hi Steve

such as Advanced Filter


http://www.rondebruin.nl/menuid.htm

Sub MenuControl_False()
' Excel 2000 - 2003
Dim Ctrl As Office.CommandBarControl
For Each Ctrl In Application.CommandBars.FindControls(ID:=901)
Ctrl.Enabled = False
Next Ctrl
End Sub

Sub MenuControl_True()
' Excel 2000 - 2003
Dim Ctrl As Office.CommandBarControl
For Each Ctrl In Application.CommandBars.FindControls(ID:=901)
Ctrl.Enabled = True
Next Ctrl
End Sub




--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Steve C" wrote in message ...
When a workbook is opened, is there any way to search all available toolbars
for the existence of a particular button (i.e., customized buttons a user may
have added in another workbook, such as Advanced Filter...) and if found,
disable it? Thanks.
--
Steve C




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Search Existing Toolbars

Hi Steve

See my site and download Ole's add-in (link is on the site)
http://www.rondebruin.nl/menuid.htm


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Steve C" wrote in message ...
Excellent, Ron. Thanks a ton! Where could I get a list of control ID
numbers (i.e., ID=901) and their descriptions?
--
Steve C


"Ron de Bruin" wrote:

Hi Steve

such as Advanced Filter


http://www.rondebruin.nl/menuid.htm

Sub MenuControl_False()
' Excel 2000 - 2003
Dim Ctrl As Office.CommandBarControl
For Each Ctrl In Application.CommandBars.FindControls(ID:=901)
Ctrl.Enabled = False
Next Ctrl
End Sub

Sub MenuControl_True()
' Excel 2000 - 2003
Dim Ctrl As Office.CommandBarControl
For Each Ctrl In Application.CommandBars.FindControls(ID:=901)
Ctrl.Enabled = True
Next Ctrl
End Sub




--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Steve C" wrote in message ...
When a workbook is opened, is there any way to search all available toolbars
for the existence of a particular button (i.e., customized buttons a user may
have added in another workbook, such as Advanced Filter...) and if found,
disable it? Thanks.
--
Steve C


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Search Existing Toolbars

Thanks for your input, Jay. It is appreciated!
--
Steve C


"Jay" wrote:

Hi Steve -

Sub SteveC()
For Each cmdBar In Application.CommandBars
For Each ctrl cmdBar.Controls
If ctrl.Caption = "&Advanced Filter..." Then 'Adjust name to suite*
With ctrl
.Visible = True 'True or False to suit
.Enabled = False 'True or False to suit
End With
End If
Next 'ctrl
Next 'cmdBar
End Sub

*Footnote: To find the exact name of the control (button) you're interested
in, rightclick in any toolbar, select 'Customize...' and then rightclick the
button to see its Name property.

Reminder: Any change you make with the above code is completely reversible,
but is 'permanent' until explicitly reversed by the above code (change false
to true or vice versa) or by some other existing code. The modified toolbar
is saved when excel closes.
--
Jay


"Steve C" wrote:

When a workbook is opened, is there any way to search all available toolbars
for the existence of a particular button (i.e., customized buttons a user may
have added in another workbook, such as Advanced Filter...) and if found,
disable it? Thanks.
--
Steve C

  #8   Report Post  
Posted to microsoft.public.excel.programming
Jay Jay is offline
external usenet poster
 
Posts: 671
Default Search Existing Toolbars

Thanks Ron, excellent solution. More universal and robust to use ID's.
Casual users may find it tricky to track down ID's (if they don't know 'bout
your website !), so I figured Steve (and others) might benefit from two
approaches.

Keep up the good work - your website is a treasure.
--
Jay


"Ron de Bruin" wrote:

Hi Jay

See my reply that use the ID together with findcontrol.
Working in other languages also then

--
Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Jay" wrote in message ...
Hi Steve -

Sub SteveC()
For Each cmdBar In Application.CommandBars
For Each ctrl cmdBar.Controls
If ctrl.Caption = "&Advanced Filter..." Then 'Adjust name to suite*
With ctrl
.Visible = True 'True or False to suit
.Enabled = False 'True or False to suit
End With
End If
Next 'ctrl
Next 'cmdBar
End Sub

*Footnote: To find the exact name of the control (button) you're interested
in, rightclick in any toolbar, select 'Customize...' and then rightclick the
button to see its Name property.

Reminder: Any change you make with the above code is completely reversible,
but is 'permanent' until explicitly reversed by the above code (change false
to true or vice versa) or by some other existing code. The modified toolbar
is saved when excel closes.
--
Jay


"Steve C" wrote:

When a workbook is opened, is there any way to search all available toolbars
for the existence of a particular button (i.e., customized buttons a user may
have added in another workbook, such as Advanced Filter...) and if found,
disable it? Thanks.
--
Steve C


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
Formatting worksheets, existing and new, in existing workbooks G. Dagger[_2_] Excel Discussion (Misc queries) 4 January 7th 08 06:48 PM
Create Worksheet From Values in Existing Cells Using Existing Worksheet as Template. Ardy Excel Programming 18 November 29th 06 03:23 AM
download existing spreadsheets into another existing spreadsheet lbierer Excel Discussion (Misc queries) 2 September 24th 06 08:36 PM
Please Help, No Toolbars in my view-toolbars! [email protected] Excel Programming 2 February 19th 05 09:15 PM
Search for existing values in woorksheet!? Daniel[_10_] Excel Programming 4 May 4th 04 12:02 PM


All times are GMT +1. The time now is 12:41 AM.

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"