Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Disable Cut and paste

Hi all,

I found a script in an old EEE newsletter on j-walk.com that disables cut and paste in a workbook/sheet. This is something that I need desperately as my staff insist on using cut and paste in their timesheets and it is driving me bereft. If I had a donut for every time I'd told them not to do it I'd need Greenpeace to protect me.

Basically it works and does what I require except that on Workbook_Open I get a debug msg box. If I select "run" the macro works. This is a bit annoying. On "debug" the editor goes to:

Sub EnableControl(Id As Integer, Enabled As Boolean)
Dim CB As CommandBar
Dim C As CommandBarControl
For Each CB In Application.CommandBars
Set C = CB.FindControl(Id:=Id, recursive:=True)
If Not C Is Nothing Then C.Enabled = Enabled
Next
End Sub

The more I fiddle with it the more my ignorance shows. Any help will be appreciated.

the script is at http://www.j-walk.com/ss/excel/eee/eee020.txt


Regards

Roy Collins.

"You don't need to be good. You just need to be able to convince people you are."
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Disable Cut and paste

Hi Roy,

Try

'=============
Public Sub EnableControl(Id As Integer, Enabled As Boolean)
Dim CB As Office.CommandBar
Dim C As CommandBarButton
For Each CB In Application.CommandBars
Set C = CB.FindControl(Id:=Id, recursive:=True)
If Not CB.Name = "Clipboard" Then
If Not C Is Nothing Then C.Enabled = Enabled
End If
Next
End Sub
'<<=============

---
Regards,
Norman


"Roy" wrote in message
...
Hi all,

I found a script in an old EEE newsletter on j-walk.com that disables cut
and paste in a workbook/sheet. This is something that I need desperately as
my staff insist on using cut and paste in their timesheets and it is driving
me bereft. If I had a donut for every time I'd told them not to do it I'd
need Greenpeace to protect me.

Basically it works and does what I require except that on Workbook_Open I
get a debug msg box. If I select "run" the macro works. This is a bit
annoying. On "debug" the editor goes to:

Sub EnableControl(Id As Integer, Enabled As Boolean)
Dim CB As CommandBar
Dim C As CommandBarControl
For Each CB In Application.CommandBars
Set C = CB.FindControl(Id:=Id, recursive:=True)
If Not C Is Nothing Then C.Enabled = Enabled
Next
End Sub

The more I fiddle with it the more my ignorance shows. Any help will be
appreciated.

the script is at http://www.j-walk.com/ss/excel/eee/eee020.txt


Regards

Roy Collins.

"You don't need to be good. You just need to be able to convince people you
are."


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Disable Cut and paste

Hi Roy,

The intended adaptation was:

'=============
Public Sub EnableControl(Id As Integer, Enabled As Boolean)
Dim CB As CommandBar
Dim C As CommandBarControl
For Each CB In Application.CommandBars
Set C = CB.FindControl(Id:=Id, recursive:=True)
If Not CB.Name = "Clipboard" Then
If Not C Is Nothing Then C.Enabled = Enabled
End If
Next
End Sub
'<<=============

---
Regards,
Norman


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
Disable cut and paste confused Excel Worksheet Functions 1 August 21st 06 11:32 AM
Disable cut paste in a workbook Narendra Nath Excel Programming 0 March 10th 06 01:42 PM
How do I disable the pop-ups that appear when I copy/paste, etc? Fiscal Al Excel Discussion (Misc queries) 1 October 31st 05 03:46 PM
disable copy paste Tim Excel Programming 7 June 30th 05 02:37 PM
Disable Paste Special Steph[_3_] Excel Programming 2 June 29th 05 06:13 PM


All times are GMT +1. The time now is 03:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"