disable cut, copy, paste, paste special, drag & Drop

Creating a macro - Writing a Script - Using the API

disable cut, copy, paste, paste special, drag & Drop

Postby fabiusf » Tue Jan 15, 2013 4:14 pm

Hi,
I must convert an excel file into calc.
To prevent errors from users i disable various commands with vba subroutines, but i can’t reproduce them in OpenOffice 3.4. Can someone help me ?
Thanks

i poste the subroutines in vba:

Code: Select all   Expand viewCollapse view
Option VBASupport 1

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

Private Sub Workbook_Activate()
Application.CutCopyMode = False
Application.OnKey “^c”, “”
Application.CellDragAndDrop = False
EnableControl 21, False ‘ cut
‘EnableControl 19, False ‘ copy
EnableControl 22, False ‘ paste
EnableControl 755, False ‘ pastespecial
Application.OnKey “^c”, “”
Application.OnKey “^v”, “”
Application.OnKey “+{DEL}”, “”
Application.OnKey “+{INSERT}”, “”
Application.CellDragAndDrop = False
End Sub

Private Sub Workbook_Deactivate()
Application.CellDragAndDrop = True
Application.OnKey “^c”
Application.CutCopyMode = 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.CellDragAndDrop = True
End Sub

Private Sub Workbook_WindowActivate(ByVal Wn As Window)
Application.CutCopyMode = False
Application.OnKey “^c”, “”
Application.CellDragAndDrop = False
End Sub

Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)

Application.CellDragAndDrop = True

Application.OnKey “^c”
‘Application.CutCopyMode = False
End Sub

Private Sub Workbook_Open()

Application.CellDragAndDrop = False
Application.ExtendList = False
Application.CutCopyMode = False

Application.CommandBars(“Cell”).Enabled = False

Application.OnKey “^x”, “”
Application.OnKey “^c”, “”
Application.OnKey “^v”, “”

EnableControl 21, False ‘ cut
‘EnableControl 19, False ‘ copy
EnableControl 22, False ‘ paste
EnableControl 755, False ‘ pastespecial
Application.OnKey “^c”, “”
Application.OnKey “^v”, “”
Application.OnKey “+{DEL}”, “”
Application.OnKey “+{INSERT}”, “”
Application.CellDragAndDrop = False
‘CONTROL if cell SEDE is empty x = Range(“sede”) If Trim(x) = “” Then Beep MsgBox “cell SEDE empty, insert data !!!!!!” End If

End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)

Application.CellDragAndDrop = True
Application.ExtendList = True
Application.CutCopyMode = True
Application.CommandBars(“Cell”).Enabled = True
Application.OnKey “^x”
Application.OnKey “^c”
Application.OnKey “^v”
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.CellDragAndDrop = True
‘CONTROL if cell SEDE is empty x = Range(“sede”) If Trim(x) = “” Then Beep MsgBox “cell SEDE empty, insert data !!!!!!” Cancel=True End if

End Sub
Last edited by RoryOF on Tue Jan 15, 2013 4:40 pm, edited 3 times in total.
Reason: Added code tags, corrected subject typo to aid searching.
fabius
User avatar
fabiusf
 
Posts: 1
Joined: Tue Jan 15, 2013 4:08 pm

Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 2 guests