PC Review


Reply
Thread Tools Rate Thread

Disable Command Bar Control

 
 
iperlovsky
Guest
Posts: n/a
 
      15th Dec 2008
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 With Quote
 
 
 
 
Ron de Bruin
Guest
Posts: n/a
 
      15th Dec 2008
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" <(E-Mail Removed)> wrote in message news:E1623908-754E-4289-B7F1-(E-Mail Removed)...
>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 With Quote
 
iperlovsky
Guest
Posts: n/a
 
      15th Dec 2008
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" <(E-Mail Removed)> wrote in message news:E1623908-754E-4289-B7F1-(E-Mail Removed)...
> >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 With Quote
 
Ron de Bruin
Guest
Posts: n/a
 
      15th Dec 2008
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" <(E-Mail Removed)> wrote in message news:14E338F1-DE4F-4A32-9259-(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message news:E1623908-754E-4289-B7F1-(E-Mail Removed)...
>> >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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using a Forms control to disable an ActiveX control exceluser Microsoft Excel Discussion 0 18th Oct 2010 02:56 AM
Disable Command Bar Edit Control iperlovsky Microsoft Excel Programming 6 12th Dec 2008 09:31 PM
Disable or lock a control based on the value of another control =?Utf-8?B?TWFyayBCYWtlcg==?= Microsoft Access Forms 3 13th Mar 2007 02:21 AM
Disable control on exit - Can't disable control that has focus... =?Utf-8?B?SkJIYW5zZW4=?= Microsoft Access Form Coding 2 19th Feb 2007 07:19 PM
Disable run as command Nick Fletcher Microsoft Windows 2000 Active Directory 3 24th Jun 2004 02:02 PM


Features
 

Advertising
 

Newsgroups
 


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