Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Disable Command Bar Control

I am trying to disable the "cut" control in the "edit" menu in the Command
Bar, as well as in any other menu where "cut" may appear. So far the below
code, which I input into the specific sheet's code window, works, but it does
not disable the key board shortcut "control x". That is but a minor problem.
The main issue is that the code disables the "cut" control in all of my
Excel files. Any ideas on how I could disable the keyboard short cut as well
make the code apply only to a particular sheet rather than to my Excel in
general? Any help is greatly appreciated.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Ctrl As Office.CommandBarControl
For Each Ctrl In Application.CommandBars.FindControls(ID:=21)
Ctrl.Enabled = False
Next Ctrl
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Disable Command Bar Control

hi iperlovsky

Use onkey
http://www.rondebruin.nl/key.htm

Use this two eventsto run your code

Private Sub Workbook_Activate()

End Sub

Private Sub Workbook_Deactivate()

End Sub


--

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


"iperlovsky" wrote in message ...
I am trying to disable the "cut" control in the "edit" menu in the Command
Bar, as well as in any other menu where "cut" may appear. So far the below
code, which I input into the specific sheet's code window, works, but it does
not disable the key board shortcut "control x". That is but a minor problem.
The main issue is that the code disables the "cut" control in all of my
Excel files. Any ideas on how I could disable the keyboard short cut as well
make the code apply only to a particular sheet rather than to my Excel in
general? Any help is greatly appreciated.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Ctrl As Office.CommandBarControl
For Each Ctrl In Application.CommandBars.FindControls(ID:=21)
Ctrl.Enabled = False
Next Ctrl
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Disable Command Bar Control

Thanks for the link Ron. Changing the code to begin with "Private Sub
Workbook_Activate()" unfortunately does not eliminate my problem of limiting
the code to be active on only the selected sheet rather than my Excel in
general. What am I doing wrong?

"Ron de Bruin" wrote:

hi iperlovsky

Use onkey
http://www.rondebruin.nl/key.htm

Use this two eventsto run your code

Private Sub Workbook_Activate()

End Sub

Private Sub Workbook_Deactivate()

End Sub


--

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


"iperlovsky" wrote in message ...
I am trying to disable the "cut" control in the "edit" menu in the Command
Bar, as well as in any other menu where "cut" may appear. So far the below
code, which I input into the specific sheet's code window, works, but it does
not disable the key board shortcut "control x". That is but a minor problem.
The main issue is that the code disables the "cut" control in all of my
Excel files. Any ideas on how I could disable the keyboard short cut as well
make the code apply only to a particular sheet rather than to my Excel in
general? Any help is greatly appreciated.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Ctrl As Office.CommandBarControl
For Each Ctrl In Application.CommandBars.FindControls(ID:=21)
Ctrl.Enabled = False
Next Ctrl
End Sub


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Disable Command Bar Control

This are events that belong in the thisworkbook module
You call the macro in the event or put all code in the event

Private Sub Workbook_Activate()
Call macroname1
End Sub

Private Sub Workbook_Deactivate()
Call macroname2
End Sub




--

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


"iperlovsky" wrote in message ...
Thanks for the link Ron. Changing the code to begin with "Private Sub
Workbook_Activate()" unfortunately does not eliminate my problem of limiting
the code to be active on only the selected sheet rather than my Excel in
general. What am I doing wrong?

"Ron de Bruin" wrote:

hi iperlovsky

Use onkey
http://www.rondebruin.nl/key.htm

Use this two eventsto run your code

Private Sub Workbook_Activate()

End Sub

Private Sub Workbook_Deactivate()

End Sub


--

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


"iperlovsky" wrote in message ...
I am trying to disable the "cut" control in the "edit" menu in the Command
Bar, as well as in any other menu where "cut" may appear. So far the below
code, which I input into the specific sheet's code window, works, but it does
not disable the key board shortcut "control x". That is but a minor problem.
The main issue is that the code disables the "cut" control in all of my
Excel files. Any ideas on how I could disable the keyboard short cut as well
make the code apply only to a particular sheet rather than to my Excel in
general? Any help is greatly appreciated.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Ctrl As Office.CommandBarControl
For Each Ctrl In Application.CommandBars.FindControls(ID:=21)
Ctrl.Enabled = False
Next Ctrl
End Sub


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
Disable Command Bar Edit Control iperlovsky Excel Programming 6 December 12th 08 06:05 PM
Disable control Francis Ang[_3_] Excel Programming 3 October 10th 06 12:16 AM
disable control vj5 Excel Programming 0 July 6th 06 07:46 AM
disable control vj5 Excel Programming 0 July 6th 06 07:45 AM
Disable Control s Dave[_18_] Excel Programming 0 July 17th 03 05:59 PM


All times are GMT +1. The time now is 03: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"