View Single Post
  #14   Report Post  
Posted to microsoft.public.excel.programming
Fable[_12_] Fable[_12_] is offline
external usenet poster
 
Posts: 1
Default Disable Print Screen Challenge

Here the code for Copy & Paste
============================
Sub DisableCopyCutAndPaste()
Application.ScreenUpdating = False
'
EnableControl 21, False ' cut
EnableControl 19, False ' copy
EnableControl 22, False ' paste
EnableControl 755, False ' pastespecial
Application.OnKey "^c", "Dummy"
Application.OnKey "^v", "Dummy"
Application.OnKey "+{DEL}", "Dummy"
Application.OnKey "+{INSERT}", "Dummy"
Application.OnKey "+{PRTSC}", "Dummy"
Application.CellDragAndDrop = False
Application.OnDoubleClick = "Dummy"
CommandBars("ToolBar List").Enabled = False
Application.CutCopyMode = True
End Sub

Sub EnableCopyCutAndPaste()
Application.ScreenUpdating = False
'
EnableControl 21, True ' cut
EnableControl 19, True ' copy
EnableControl 22, True ' paste
EnableControl 755, True ' pastespecial
Application.OnKey "^c"
Application.OnKey "^v"
Application.OnKey "+{DEL}"
Application.OnKey "+{INSERT}"
Application.OnKey "+{PRTSC}"
Application.CellDragAndDrop = True
Application.OnDoubleClick = ""
CommandBars("ToolBar List").Enabled = True
'FORCE A EMPTY CLIP BOARD
Range("A1").Select
Selection.Copy
Range("A2").Select
ActiveSheet.Paste
Range("A1").Select
Application.CutCopyMode = False
End Sub

Sub EnableControl(Id As Integer, Enabled As Boolean)
Dim CB As CommandBar
Dim C As CommandBarControl

On Error Resume Next
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

Sub Dummy()
'// NoGo
MsgBox "Sorry command not Available!"
End Sub

==================================
The solution too force people to use macro is pretty easy, in
nutshell the code below does the following, when you close you
workbook it will hide the sheets you have programmed, leaving only on
sheet visible call “ERROR” (in this case), so if the user opens th
workbook without enabling macros all they will get is the Error (wit
some type of message, like you must enable macro to access file), an
when the user does select Enable macros the code makes the sheets tha
where once hidden visible again.

'In your Workbook place this code

Private Sub Workbook_Open()
Call Unhide_Sheets
End Sub


Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call Hide_Sheets
End Sub

==================================

'Create a Module and place this code

Sub Hide_Sheets()
Application.ScreenUpdating = False
'
Sheets("Sheet1").Select
ActiveWindow.SelectedSheets.Visible = False
'
Sheets("Sheet2").Select
ActiveWindow.SelectedSheets.Visible = False
'
Sheets("Sheet3").Select
ActiveWindow.SelectedSheets.Visible = False

Sheets("ERROR").Select

Range("A1").Select
End Sub
Sub Unhide_Sheets()
Application.ScreenUpdating = False
'
Sheets("Sheet1").Visible = True
Sheets("Sheet2”).Visible = True
Sheets("Sheet3").Visible = True
Range("A1").Select
End Sub

=======================
Hope this helps!

Fabl

--
Message posted from http://www.ExcelForum.com