ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Disabling Cut Copy and Paste buttons in toolbar (https://www.excelbanter.com/excel-programming/408933-disabling-cut-copy-paste-buttons-toolbar.html)

Adrian Turner

Disabling Cut Copy and Paste buttons in toolbar
 
Hi, I'm looking for some code to disable the cut,copy and paste buttons
within the toolbar. I've foudn some for the menus, so I assume it is similar.
Struggling to find solution. If anyone has already done this, if you could
point me in the right direction it will save me some frustration. Thanks

Jim Cone

Disabling Cut Copy and Paste buttons in toolbar
 

I assume what you are looking for is a reference to the Toolbars...
Application.CommandBars("Formatting") and
Application.CommandBars (Standard")

But what about the cell right-click menu or the row/column headers right-click menu?
And there is always Ctrl + C or Ctrl + X and Ctrl + V.
Also, drag and drop is the same as cut and paste.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"Adrian Turner"
wrote in message
Hi, I'm looking for some code to disable the cut,copy and paste buttons
within the toolbar. I've foudn some for the menus, so I assume it is similar.
Struggling to find solution. If anyone has already done this, if you could
point me in the right direction it will save me some frustration. Thanks

Jim Rech[_2_]

Disabling Cut Copy and Paste buttons in toolbar
 
This routine disables/enables Cuts and Drag & Drop. You'd have to extend it
or add something similar for Copy and Paste. The ID for Copy is 19 and
Paste is 22.

''Pass True to Enable and False to Disable
Sub AllowCuts(EnableBool As Boolean)
Dim oCtls As CommandBarControls, oCtl As CommandBarControl
Set oCtls = CommandBars.FindControls(ID:=21) ''Cut
If Not oCtls Is Nothing Then
For Each oCtl In oCtls
oCtl.Enabled = EnableBool
Next
End If
Set oCtls = CommandBars.FindControls(ID:=522)
If Not oCtls Is Nothing Then
For Each oCtl In oCtls
''Disable Options so D&D cannot be restored
oCtl.Enabled = EnableBool
Next
End If
With Application
.CellDragAndDrop = EnableBool
If EnableBool Then
.OnKey "^x"
.OnKey "+{Del}"
Else
.OnKey "^x", ""
.OnKey "+{Del}", ""
End If
End With
End Sub


--
Jim
"Adrian Turner" wrote in message
...
| Hi, I'm looking for some code to disable the cut,copy and paste buttons
| within the toolbar. I've foudn some for the menus, so I assume it is
similar.
| Struggling to find solution. If anyone has already done this, if you could
| point me in the right direction it will save me some frustration. Thanks



Jialiang Ge [MSFT]

Disabling Cut Copy and Paste buttons in toolbar
 
Hello Adrian,

I agree with Jim Rech, and apart from his macro, I find another one at:
http://www.ozgrid.com/VBA/disable-cut-copy.htm
It calls Application.CellDragAndDrop = False and Application.CutCopyMode =
False to disable cut/copy, however, it doesn't disable the Paste behavior.
To disable Paste, I'd suggest Jim's routine:

Sub AllowPastes(EnableBool As Boolean)
Dim oCtls As CommandBarControls, oCtl As CommandBarControl
Set oCtls = CommandBars.FindControls(ID:=22) ''Paste
If Not oCtls Is Nothing Then
For Each oCtl In oCtls
oCtl.Enabled = EnableBool
Next
End If
Set oCtls = CommandBars.FindControls(ID:=522)
If Not oCtls Is Nothing Then
For Each oCtl In oCtls
''Disable Options so D&D cannot be restored
oCtl.Enabled = EnableBool
Next
End If
With Application
.CellDragAndDrop = EnableBool
If EnableBool Then
.OnKey "^v"
.OnKey "+{Del}"
Else
.OnKey "^v", ""
.OnKey "+{Del}", ""
End If
End With
End Sub

The complete command bar control ID list can be found at
http://support.microsoft.com/kb/213552

If you have any other concerns or questions, feel free to let me know

Regards,
Jialiang Ge , remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


Jialiang Ge [MSFT]

Disabling Cut Copy and Paste buttons in toolbar
 
Hi Adrian,

I am wrting to check the status of the issue on your side. Would you mind
letting me know the result of the suggestions? If you need further
assistance, feel free to let me know. I will be more than happy to be of
assistance.

Have a great day!

Regards,
Jialiang Ge , remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
.

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================



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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com