Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Turning Off Cut & Copy in a Workbook


Hi,

Below is some code I finally found or worked out to stop operators from
using cut & copy in a workbook.
Hope this saves some painstaking research for someone else.


Sub CommandBarsOFF()
'This macro disables the edit options off the top commandbars
' CommandBarsOFF Macro

Application.CommandBars("cell").Enabled = False
CommandBars("Edit").Enabled = False
End Sub


Sub MyToolbar()
'This Macro is a guide for you to make your own customised toolbar, mine is
called "Autonite"
' MyToolbar

Application.CommandBars("Standard").Visible = False
Application.CommandBars("Formatting").Visible = False
Application.CommandBars("Visual Basic").Visible = False
Application.CommandBars("WordArt").Visible = False

Set mybar = CommandBars _
.Add(Name:="Autonite", Position:=msoBarTop, _
Temporary:=True)
With mybar
.Controls.Add Type:=msoControlButton, ID:= _
CommandBars("File").Controls("Save").ID
.Visible = True
End With

Application.CommandBars("Autonite").Controls.Add Type:=msoControlButton,
ID _
:=109, Befo=2
Application.CommandBars("Autonite").Controls.Add Type:=msoControlButton,
ID _
:=4, Befo=3
Application.CommandBars("Autonite").Controls.Add Type:= _
msoControlSplitDropdown, ID:=128, Befo=4
Application.CommandBars("Autonite").Controls.Add Type:= _
msoControlSplitDropdown, ID:=129, Befo=5
Application.CommandBars("Autonite").Controls.Add Type:=msoControlButton,
ID _
:=444, Befo=6
' etc etc - just keep adding until you have what you want
End Sub

Sub DisableControlC()
'
' Keyboard Shortcut: Ctrl+c
'To run the macro by pressing a keyboard shortcut key, enter a letter in the
Shortcut key box.
'The shortcut key will override any default Microsoft Excel shortcut keys
while the workbook that contains the macro is open.

Dim Prompt1, Style1, Title1, Response1 As String
Prompt1 = "CUT and COPY (Control X and Control C) have been disabled on
this workbook!" & Chr(13) _
& Chr(13) _
Style1 = vbOKOnly + vbExclamation ' Define buttons used in prompt.
Title1 = "CUT AND COPY HAVE BEEN DISABLED!"
Response1 = MsgBox(Prompt1, Style1, Title1)
End Sub


Sub DisableControlX()
'
' Keyboard Shortcut: Ctrl+x
'To run the macro by pressing a keyboard shortcut key, enter a letter in the
Shortcut key box.
'The shortcut key will override any default Microsoft Excel shortcut keys
while the workbook that contains the macro is open.

Dim Prompt1, Style1, Title1, Response1 As String
Prompt1 = "CUT and COPY (Control X and Control C) have been disabled on
this workbook!" & Chr(13) _
& Chr(13) _
Style1 = vbOKOnly + vbExclamation ' Define buttons used in prompt.
Title1 = "CUT AND COPY HAVE BEEN DISABLED!"
Response1 = MsgBox(Prompt1, Style1, Title1)
End Sub


I used Auto_Open() and Auto_Close() to contol how I wanted the workbook to
open and shut.

' auto_open Macro
' This macro runs the macros called MyToolbar and CommandBarsOFF

Sub auto_open()
MyToolbar
CommandBarsOFF
Application.DisplayFormulaBar = True
End Sub

Sub auto_close()
' auto_close Macro
'
DeleteMyToolbar
CommandBarsON
End Sub

'You need the following macro's to reset everything when you exit the
workbook.

Sub CommandBarsON()
'This macro enables the edit options off the top commandbars

Application.CommandBars("cell").Enabled = True
CommandBars("Edit").Enabled = True
End Sub

Sub DeleteMyToolbar()
'This macro deletes the customised toolbar made from running the MyToolbar
macro.
' DeleteMyToolbar Macro

Application.CommandBars("Autonite").Delete
End Sub


Regards,

Wazza McG
No email replies please - reply to the newsgroup!



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Turning Off Cut & Copy in a Workbook

This line of code inserted in the workbook module will stop cut/copy/paste
from between ranges.
Be aware though the user can still paste from the formula bar and other
applications.

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)
Application.CutCopyMode = False
End Sub


--
Regards,
Rocky McKinley


"Wazza McG" wrote in message
u...

Hi,

Below is some code I finally found or worked out to stop operators from
using cut & copy in a workbook.
Hope this saves some painstaking research for someone else.


Sub CommandBarsOFF()
'This macro disables the edit options off the top commandbars
' CommandBarsOFF Macro

Application.CommandBars("cell").Enabled = False
CommandBars("Edit").Enabled = False
End Sub


Sub MyToolbar()
'This Macro is a guide for you to make your own customised toolbar, mine

is
called "Autonite"
' MyToolbar

Application.CommandBars("Standard").Visible = False
Application.CommandBars("Formatting").Visible = False
Application.CommandBars("Visual Basic").Visible = False
Application.CommandBars("WordArt").Visible = False

Set mybar = CommandBars _
.Add(Name:="Autonite", Position:=msoBarTop, _
Temporary:=True)
With mybar
.Controls.Add Type:=msoControlButton, ID:= _
CommandBars("File").Controls("Save").ID
.Visible = True
End With

Application.CommandBars("Autonite").Controls.Add

Type:=msoControlButton,
ID _
:=109, Befo=2
Application.CommandBars("Autonite").Controls.Add

Type:=msoControlButton,
ID _
:=4, Befo=3
Application.CommandBars("Autonite").Controls.Add Type:= _
msoControlSplitDropdown, ID:=128, Befo=4
Application.CommandBars("Autonite").Controls.Add Type:= _
msoControlSplitDropdown, ID:=129, Befo=5
Application.CommandBars("Autonite").Controls.Add

Type:=msoControlButton,
ID _
:=444, Befo=6
' etc etc - just keep adding until you have what you want
End Sub

Sub DisableControlC()
'
' Keyboard Shortcut: Ctrl+c
'To run the macro by pressing a keyboard shortcut key, enter a letter in

the
Shortcut key box.
'The shortcut key will override any default Microsoft Excel shortcut keys
while the workbook that contains the macro is open.

Dim Prompt1, Style1, Title1, Response1 As String
Prompt1 = "CUT and COPY (Control X and Control C) have been disabled

on
this workbook!" & Chr(13) _
& Chr(13) _
Style1 = vbOKOnly + vbExclamation ' Define buttons used in prompt.
Title1 = "CUT AND COPY HAVE BEEN DISABLED!"
Response1 = MsgBox(Prompt1, Style1, Title1)
End Sub


Sub DisableControlX()
'
' Keyboard Shortcut: Ctrl+x
'To run the macro by pressing a keyboard shortcut key, enter a letter in

the
Shortcut key box.
'The shortcut key will override any default Microsoft Excel shortcut keys
while the workbook that contains the macro is open.

Dim Prompt1, Style1, Title1, Response1 As String
Prompt1 = "CUT and COPY (Control X and Control C) have been disabled

on
this workbook!" & Chr(13) _
& Chr(13) _
Style1 = vbOKOnly + vbExclamation ' Define buttons used in prompt.
Title1 = "CUT AND COPY HAVE BEEN DISABLED!"
Response1 = MsgBox(Prompt1, Style1, Title1)
End Sub


I used Auto_Open() and Auto_Close() to contol how I wanted the workbook to
open and shut.

' auto_open Macro
' This macro runs the macros called MyToolbar and CommandBarsOFF

Sub auto_open()
MyToolbar
CommandBarsOFF
Application.DisplayFormulaBar = True
End Sub

Sub auto_close()
' auto_close Macro
'
DeleteMyToolbar
CommandBarsON
End Sub

'You need the following macro's to reset everything when you exit the
workbook.

Sub CommandBarsON()
'This macro enables the edit options off the top commandbars

Application.CommandBars("cell").Enabled = True
CommandBars("Edit").Enabled = True
End Sub

Sub DeleteMyToolbar()
'This macro deletes the customised toolbar made from running the MyToolbar
macro.
' DeleteMyToolbar Macro

Application.CommandBars("Autonite").Delete
End Sub


Regards,

Wazza McG
No email replies please - reply to the newsgroup!





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
Macro to copy an image (or picture) from one workbook to a new sheetin another workbook Ruchir Excel Worksheet Functions 1 July 25th 08 07:29 AM
Excel-how to link source workbook to copy of destination workbook D Lynn Excel Worksheet Functions 1 May 29th 08 05:36 PM
Copy cells based on conditions in one workbook to another workbook fLiPMoD£ Excel Discussion (Misc queries) 0 August 1st 07 07:43 PM
copy worksheet from closed workbook to active workbook using vba mango Excel Worksheet Functions 6 December 9th 04 07:55 AM
Turning off Cut and Copy? Warren McGoldrick Excel Programming 6 December 7th 03 09:35 PM


All times are GMT +1. The time now is 04:28 PM.

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"