PC Review


Reply
Thread Tools Rate Thread

Disable Command Bar Edit Control

 
 
iperlovsky
Guest
Posts: n/a
 
      12th Dec 2008
I am attempting to use this sub routine to disable the cut control under the
Edit menu and all the sub menus, but the menu is still allowing me to cut. I
have Excel 2003. Any help is appreciated.

Sub MenuControl_False()
Dim Ctrl As Office.CommandBarControl
For Each Ctrl In Application.CommandBars.FindControls(ID:=21)
Ctrl.Enabled = False
Next Ctrl
End Sub

 
Reply With Quote
 
 
 
 
Michael
Guest
Posts: n/a
 
      12th Dec 2008
You're probably refering to Ctrl X
This is how you do that:
'Divert Ctrl + X = Cut
Application.OnKey "^x", "NoNo"

--
If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.




"iperlovsky" wrote:

> I am attempting to use this sub routine to disable the cut control under the
> Edit menu and all the sub menus, but the menu is still allowing me to cut. I
> have Excel 2003. Any help is appreciated.
>
> Sub MenuControl_False()
> Dim Ctrl As Office.CommandBarControl
> For Each Ctrl In Application.CommandBars.FindControls(ID:=21)
> Ctrl.Enabled = False
> Next Ctrl
> End Sub
>

 
Reply With Quote
 
Michael
Guest
Posts: n/a
 
      12th Dec 2008
Read also this:
http://www.mrexcel.com/archive/VBA/1981.html
--
If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.




"iperlovsky" wrote:

> I am attempting to use this sub routine to disable the cut control under the
> Edit menu and all the sub menus, but the menu is still allowing me to cut. I
> have Excel 2003. Any help is appreciated.
>
> Sub MenuControl_False()
> Dim Ctrl As Office.CommandBarControl
> For Each Ctrl In Application.CommandBars.FindControls(ID:=21)
> Ctrl.Enabled = False
> Next Ctrl
> End Sub
>

 
Reply With Quote
 
Michael
Guest
Posts: n/a
 
      12th Dec 2008
And if you don't want to write the nono sub, do this:
Application.OnKey "^x", ""
--
If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.




"Michael" wrote:

> You're probably refering to Ctrl X
> This is how you do that:
> 'Divert Ctrl + X = Cut
> Application.OnKey "^x", "NoNo"
>
> --
> If this posting was helpful, please click on the Yes button.
> Regards,
>
> Michael Arch.
>
>
>
>
> "iperlovsky" wrote:
>
> > I am attempting to use this sub routine to disable the cut control under the
> > Edit menu and all the sub menus, but the menu is still allowing me to cut. I
> > have Excel 2003. Any help is appreciated.
> >
> > Sub MenuControl_False()
> > 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
 
      12th Dec 2008
I am trying to disable the "cut" control from all menus in sheet 1.

"Michael" wrote:

> You're probably refering to Ctrl X
> This is how you do that:
> 'Divert Ctrl + X = Cut
> Application.OnKey "^x", "NoNo"
>
> --
> If this posting was helpful, please click on the Yes button.
> Regards,
>
> Michael Arch.
>
>
>
>
> "iperlovsky" wrote:
>
> > I am attempting to use this sub routine to disable the cut control under the
> > Edit menu and all the sub menus, but the menu is still allowing me to cut. I
> > have Excel 2003. Any help is appreciated.
> >
> > Sub MenuControl_False()
> > 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
 
      12th Dec 2008
I do not know why but none of these "grey out" (ie, disable) the cut command
from all menus in the sheet.

"Michael" wrote:

> Read also this:
> http://www.mrexcel.com/archive/VBA/1981.html
> --
> If this posting was helpful, please click on the Yes button.
> Regards,
>
> Michael Arch.
>
>
>
>
> "iperlovsky" wrote:
>
> > I am attempting to use this sub routine to disable the cut control under the
> > Edit menu and all the sub menus, but the menu is still allowing me to cut. I
> > have Excel 2003. Any help is appreciated.
> >
> > Sub MenuControl_False()
> > 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
 
      12th Dec 2008
Thanks for the tip. I am having difficulty applying this to only a few
designated sheets, rather than to the whole workbook. Any suggestions on that?

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

Thanks,

IP
"Mike H" wrote:

> Hi,
>
> All the techniques are described here
>
> http://www.rondebruin.nl/menuid.htm
>
> Mike
>
> "iperlovsky" wrote:
>
> > I am attempting to use this sub routine to disable the cut control under the
> > Edit menu and all the sub menus, but the menu is still allowing me to cut. I
> > have Excel 2003. Any help is appreciated.
> >
> > Sub MenuControl_False()
> > 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
Disable Command Bar Control iperlovsky Microsoft Excel Programming 3 15th Dec 2008 06:54 PM
copy command is disable under edit menu =?Utf-8?B?QW5pcmJhbiBEdXR0YQ==?= Microsoft Excel Misc 2 22nd Mar 2007 10:56 AM
Disable the Delete Control in the Edit Menu =?Utf-8?B?VmlydHVhbCBIaWxsYmlsbHk=?= Microsoft Excel Programming 1 23rd Jul 2006 10:50 AM
Disable File, Edit, View, etc. command bars Danny Microsoft Excel Worksheet Functions 2 16th Mar 2004 06:06 PM
Disable the Edit menu command 'Paste Special' George Raymond Microsoft Excel Programming 4 22nd Dec 2003 04:44 AM


Features
 

Advertising
 

Newsgroups
 


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