Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro to copy an image (or picture) from one workbook to a new sheetin another workbook | Excel Worksheet Functions | |||
Excel-how to link source workbook to copy of destination workbook | Excel Worksheet Functions | |||
Copy cells based on conditions in one workbook to another workbook | Excel Discussion (Misc queries) | |||
copy worksheet from closed workbook to active workbook using vba | Excel Worksheet Functions | |||
Turning off Cut and Copy? | Excel Programming |