Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 325
Default Disabling ALL commands on CELL Shortcut menu

Good afternoon, all!

Following on from earlier postings, I was previously able to delete all the
commands from the CELL shortcut menu and add two new menu items using the
following code:

Dim SCCellMenu As CommandBar
On Error Resume Next
Application.CommandBars("Cell").Reset
On Error GoTo 0
Set SCCellMenu = CommandBars("Cell")

With SCCellMenu
.Controls("Cut").Delete
.Controls("Copy").Delete
.Controls("Paste").Delete
.Controls("Paste Special...").Delete
.Controls("Insert Copied Cells...").Delete
.Controls("Insert...").Delete
.Controls("Delete...").Delete
.Controls("Clear Contents").Delete
.Controls("Insert Comment").Delete
.Controls("Format Cells...").Delete
.Controls("Pick From List...").Delete
.Controls("Hyperlink...").Delete
End With

With SCCellMenu.Controls.Add(Type:=msoControlButton)
.Caption = "&Insert Row"
.FaceId = 3194
.OnAction = "RowInsert"
End With
With SCCellMenu.Controls.Add(Type:=msoControlButton)
.Caption = "&Delete Row"
.FaceId = 293
.OnAction = "RowDelete"
End With
End Sub

The problem now arises that sometimes the Cell menu contains "Insert..." and
sometimes it contains "Insert Copied Cells...", which I assume are mutually
exclusive, so I can't have both in my code.

My question is, how do I test to see if a particular command is displayed
before I delete it, failing that, can I simply delete all commands using
something like the following:


'-------------------------------------------------------------------------------------------
'Disable commands on CELL shortcut menu like this, as sometimes "Insert"
and
'sometimes "Insert Copied Cells" is displayed
Dim SCCellMenuControl As CommandBarControl
X For Each SCCellMenuControl In SCCellMenu
SCCellMenuControl.Delete
Next

'-------------------------------------------------------------------------------------------
which incidentally doesn't work as it says "Object doesn't support this
property or method for the line beginning with the X.

I await your thoughts, VBA Jedi!

Regards and thanks in advance

Pete
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Disabling ALL commands on CELL Shortcut menu

Dim octl As Object
On Error Resume Next
Set octl = SCCellMenu.Controls("Insert")
If Not octl Is Nothing Then
octl.Delete
End If
Set octl = Nothing
Set octl = SCCellMenu.Controls("Insert Row")
If Not octl Is Nothing Then
octl.Delete
End If
On Error GoTo 0

--
HTH

Bob Phillips

"Peter Rooney" wrote in message
...
Good afternoon, all!

Following on from earlier postings, I was previously able to delete all

the
commands from the CELL shortcut menu and add two new menu items using the
following code:

Dim SCCellMenu As CommandBar
On Error Resume Next
Application.CommandBars("Cell").Reset
On Error GoTo 0
Set SCCellMenu = CommandBars("Cell")

With SCCellMenu
.Controls("Cut").Delete
.Controls("Copy").Delete
.Controls("Paste").Delete
.Controls("Paste Special...").Delete
.Controls("Insert Copied Cells...").Delete
.Controls("Insert...").Delete
.Controls("Delete...").Delete
.Controls("Clear Contents").Delete
.Controls("Insert Comment").Delete
.Controls("Format Cells...").Delete
.Controls("Pick From List...").Delete
.Controls("Hyperlink...").Delete
End With

With SCCellMenu.Controls.Add(Type:=msoControlButton)
.Caption = "&Insert Row"
.FaceId = 3194
.OnAction = "RowInsert"
End With
With SCCellMenu.Controls.Add(Type:=msoControlButton)
.Caption = "&Delete Row"
.FaceId = 293
.OnAction = "RowDelete"
End With
End Sub

The problem now arises that sometimes the Cell menu contains "Insert..."

and
sometimes it contains "Insert Copied Cells...", which I assume are

mutually
exclusive, so I can't have both in my code.

My question is, how do I test to see if a particular command is displayed
before I delete it, failing that, can I simply delete all commands using
something like the following:



'---------------------------------------------------------------------------
----------------
'Disable commands on CELL shortcut menu like this, as sometimes

"Insert"
and
'sometimes "Insert Copied Cells" is displayed
Dim SCCellMenuControl As CommandBarControl
X For Each SCCellMenuControl In SCCellMenu
SCCellMenuControl.Delete
Next


'---------------------------------------------------------------------------
----------------
which incidentally doesn't work as it says "Object doesn't support this
property or method for the line beginning with the X.

I await your thoughts, VBA Jedi!

Regards and thanks in advance

Pete



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 325
Default Disabling ALL commands on CELL Shortcut menu

Bob,

If Not SolutionDoesntWork then
SayThankYouToBob
End If

Thank you, Bob!

Regards

Pete

"Bob Phillips" wrote:

Dim octl As Object
On Error Resume Next
Set octl = SCCellMenu.Controls("Insert")
If Not octl Is Nothing Then
octl.Delete
End If
Set octl = Nothing
Set octl = SCCellMenu.Controls("Insert Row")
If Not octl Is Nothing Then
octl.Delete
End If
On Error GoTo 0

--
HTH

Bob Phillips

"Peter Rooney" wrote in message
...
Good afternoon, all!

Following on from earlier postings, I was previously able to delete all

the
commands from the CELL shortcut menu and add two new menu items using the
following code:

Dim SCCellMenu As CommandBar
On Error Resume Next
Application.CommandBars("Cell").Reset
On Error GoTo 0
Set SCCellMenu = CommandBars("Cell")

With SCCellMenu
.Controls("Cut").Delete
.Controls("Copy").Delete
.Controls("Paste").Delete
.Controls("Paste Special...").Delete
.Controls("Insert Copied Cells...").Delete
.Controls("Insert...").Delete
.Controls("Delete...").Delete
.Controls("Clear Contents").Delete
.Controls("Insert Comment").Delete
.Controls("Format Cells...").Delete
.Controls("Pick From List...").Delete
.Controls("Hyperlink...").Delete
End With

With SCCellMenu.Controls.Add(Type:=msoControlButton)
.Caption = "&Insert Row"
.FaceId = 3194
.OnAction = "RowInsert"
End With
With SCCellMenu.Controls.Add(Type:=msoControlButton)
.Caption = "&Delete Row"
.FaceId = 293
.OnAction = "RowDelete"
End With
End Sub

The problem now arises that sometimes the Cell menu contains "Insert..."

and
sometimes it contains "Insert Copied Cells...", which I assume are

mutually
exclusive, so I can't have both in my code.

My question is, how do I test to see if a particular command is displayed
before I delete it, failing that, can I simply delete all commands using
something like the following:



'---------------------------------------------------------------------------
----------------
'Disable commands on CELL shortcut menu like this, as sometimes

"Insert"
and
'sometimes "Insert Copied Cells" is displayed
Dim SCCellMenuControl As CommandBarControl
X For Each SCCellMenuControl In SCCellMenu
SCCellMenuControl.Delete
Next


'---------------------------------------------------------------------------
----------------
which incidentally doesn't work as it says "Object doesn't support this
property or method for the line beginning with the X.

I await your thoughts, VBA Jedi!

Regards and thanks in advance

Pete




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Disabling ALL commands on CELL Shortcut menu

or just
On Error Resume Next
SCCellMenu.Controls("Insert").Delete
SCCellMenu.Controls("Insert Row").Delete
On Error goto 0

If you were really asking how to delete them.

--
Regards,
Tom Ogilvy

"Peter Rooney" wrote in message
...
Bob,

If Not SolutionDoesntWork then
SayThankYouToBob
End If

Thank you, Bob!

Regards

Pete

"Bob Phillips" wrote:

Dim octl As Object
On Error Resume Next
Set octl = SCCellMenu.Controls("Insert")
If Not octl Is Nothing Then
octl.Delete
End If
Set octl = Nothing
Set octl = SCCellMenu.Controls("Insert Row")
If Not octl Is Nothing Then
octl.Delete
End If
On Error GoTo 0

--
HTH

Bob Phillips

"Peter Rooney" wrote in message
...
Good afternoon, all!

Following on from earlier postings, I was previously able to delete

all
the
commands from the CELL shortcut menu and add two new menu items using

the
following code:

Dim SCCellMenu As CommandBar
On Error Resume Next
Application.CommandBars("Cell").Reset
On Error GoTo 0
Set SCCellMenu = CommandBars("Cell")

With SCCellMenu
.Controls("Cut").Delete
.Controls("Copy").Delete
.Controls("Paste").Delete
.Controls("Paste Special...").Delete
.Controls("Insert Copied Cells...").Delete
.Controls("Insert...").Delete
.Controls("Delete...").Delete
.Controls("Clear Contents").Delete
.Controls("Insert Comment").Delete
.Controls("Format Cells...").Delete
.Controls("Pick From List...").Delete
.Controls("Hyperlink...").Delete
End With

With SCCellMenu.Controls.Add(Type:=msoControlButton)
.Caption = "&Insert Row"
.FaceId = 3194
.OnAction = "RowInsert"
End With
With SCCellMenu.Controls.Add(Type:=msoControlButton)
.Caption = "&Delete Row"
.FaceId = 293
.OnAction = "RowDelete"
End With
End Sub

The problem now arises that sometimes the Cell menu contains

"Insert..."
and
sometimes it contains "Insert Copied Cells...", which I assume are

mutually
exclusive, so I can't have both in my code.

My question is, how do I test to see if a particular command is

displayed
before I delete it, failing that, can I simply delete all commands

using
something like the following:




'---------------------------------------------------------------------------
----------------
'Disable commands on CELL shortcut menu like this, as sometimes

"Insert"
and
'sometimes "Insert Copied Cells" is displayed
Dim SCCellMenuControl As CommandBarControl
X For Each SCCellMenuControl In SCCellMenu
SCCellMenuControl.Delete
Next



'---------------------------------------------------------------------------
----------------
which incidentally doesn't work as it says "Object doesn't support

this
property or method for the line beginning with the X.

I await your thoughts, VBA Jedi!

Regards and thanks in advance

Pete






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
Disabling Right Click Menu Tom Excel Programming 2 August 18th 04 06:57 AM
Disabling Menu Options Neil Warwick Excel Programming 1 January 18th 04 10:02 PM
Disabling Commands Loomah Excel Programming 1 January 16th 04 12:52 PM
Disabling the CONTROL + BREAK shortcut key function - HAVING PROBLEM - MY CODE DOES NOT WORK Marcello do Guzman Excel Programming 0 January 15th 04 02:41 AM
Disabling Shortcut Hot Keys Dan Gesshel Excel Programming 1 September 15th 03 09:12 PM


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