View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Wazza McG[_3_] Wazza McG[_3_] is offline
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!