PC Review


Reply
Thread Tools Rate Thread

Disabling Cut Copy and Paste buttons in toolbar

 
 
Adrian Turner
Guest
Posts: n/a
 
      7th Apr 2008
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
 
Reply With Quote
 
 
 
 
Jim Cone
Guest
Posts: n/a
 
      7th Apr 2008

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
 
Reply With Quote
 
Jim Rech
Guest
Posts: n/a
 
      7th Apr 2008
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" <(E-Mail Removed)> wrote in message
news:7E9A9B7F-BF9A-4B65-A9A6-(E-Mail Removed)...
| 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


 
Reply With Quote
 
Jialiang Ge [MSFT]
Guest
Posts: n/a
 
      8th Apr 2008
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 ((E-Mail Removed), 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:
(E-Mail Removed).

==================================================
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.

 
Reply With Quote
 
Jialiang Ge [MSFT]
Guest
Posts: n/a
 
      10th Apr 2008
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 ((E-Mail Removed), 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:
(E-Mail Removed).

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

 
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
Disabling Toolbar buttons =?Utf-8?B?VG9t?= Microsoft Dot NET Framework Forms 2 5th May 2004 09:21 PM
Disabling toolbar buttons =?Utf-8?B?bWFya2Vib3k=?= Microsoft VB .NET 1 10th Feb 2004 04:02 AM
Disabling Toolbar Buttons with no open Workbook Paul Martin Microsoft Excel Programming 1 28th Oct 2003 10:27 PM
Disabling Toolbar buttons and CommandBar items Jim Microsoft Excel Programming 2 14th Aug 2003 02:33 PM
Alpha blending with Toolbar and Disabling buttons makes button dark gray Philippe Meunier Microsoft Dot NET 0 24th Jul 2003 03:48 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:10 AM.