OVH Cloud OVH Cloud

Interdire le copier/coller dans une feille protegee

4 réponses
Avatar
loadmaster
Y-a-t-il une astuce pour empecher un copier/coller de cellules non protegées dans une feuille protegée

Mci et slts

4 réponses

Avatar
anonymous
il ny a pas d'astuce mais des programmes VBA pour pouvoir interdire le copier-coller sont nombreux.
Le nombre d'instructions à passer est important car le nombre de manières de copier-coller sous Excel est très riche. Je t'indique une manière parmi d'autres.
Il te faut placer ce code dans le module Thisworkbook dans la proédure évenementielle Open

On Error Resume Next
With Application
'disables shortcut keys
.OnKey "^c", ""
.OnKey "^v", ""
.OnKey "^x", ""
'Disables Copy
.CommandBars("Edit").FindControl(ID:).Enabled = False
.CommandBars("Edit").FindControl(ID:„8).Enabled = False
.CommandBars("Cell").FindControl(ID:).Enabled = False
.CommandBars("Column").FindControl(ID:).Enabled = False
.CommandBars("Row").FindControl(ID:).Enabled = False
.CommandBars("Button").FindControl(ID:).Enabled = False
.CommandBars("Formula Bar").FindControl(ID:).Enabled = False
.CommandBars("Worksheet Menu Bar").FindControl(ID:).Enabled = False
.CommandBars("Standard").FindControl(ID:).Enabled = False
.CommandBars("Button").FindControl(ID:„8).Enabled = False
.CommandBars("Formula Bar").FindControl(ID:„8).Enabled = False
.CommandBars("Worksheet Menu Bar").FindControl(ID:„8).Enabled = False
.CommandBars("Standard").FindControl(ID:„8).Enabled = False
.CommandBars("Ply").FindControl(ID:„8).Enabled = False
'Disables Cut
.CommandBars("Edit").FindControl(ID:!).Enabled = False
.CommandBars("Cell").FindControl(ID:!).Enabled = False
.CommandBars("Column").FindControl(ID:!).Enabled = False
.CommandBars("Row").FindControl(ID:!).Enabled = False
.CommandBars("Button").FindControl(ID:!).Enabled = False
.CommandBars("Formula Bar").FindControl(ID:!).Enabled = False
.CommandBars("Worksheet Menu Bar").FindControl(ID:!).Enabled = False
.CommandBars("Standard").FindControl(ID:!).Enabled = False

End With

si tu veux rétablir les commandes mettre dans la procdure evenenmentielle before close de THisworkbook les commandes suivantes

On Error Resume Next
With Application
.OnKey "^c"
.OnKey "^v"
.OnKey "^x"

'Enables Copy
.CommandBars("Edit").FindControl(ID:).Enabled = True
.CommandBars("Edit").FindControl(ID:„8).Enabled = True
.CommandBars("Cell").FindControl(ID:).Enabled = True
.CommandBars("Column").FindControl(ID:).Enabled = True
.CommandBars("Row").FindControl(ID:).Enabled = True
.CommandBars("Button").FindControl(ID:).Enabled = True
.CommandBars("Formula Bar").FindControl(ID:).Enabled = True
.CommandBars("Worksheet Menu Bar").FindControl(ID:).Enabled = True
.CommandBars("Standard").FindControl(ID:).Enabled = True
.CommandBars("Button").FindControl(ID:„8).Enabled = True
.CommandBars("Formula Bar").FindControl(ID:„8).Enabled = True
.CommandBars("Worksheet Menu Bar").FindControl(ID:„8).Enabled = True
.CommandBars("Standard").FindControl(ID:„8).Enabled = True
.CommandBars("Ply").FindControl(ID:„8).Enabled = True
' Enables Cut
.CommandBars("Edit").FindControl(ID:!).Enabled = True
.CommandBars("Cell").FindControl(ID:!).Enabled = True
.CommandBars("Column").FindControl(ID:!).Enabled = True
.CommandBars("Row").FindControl(ID:!).Enabled = True
.CommandBars("Button").FindControl(ID:!).Enabled = True
.CommandBars("Formula Bar").FindControl(ID:!).Enabled = True
.CommandBars("Worksheet Menu Bar").FindControl(ID:!).Enabled = True
.CommandBars("Standard").FindControl(ID:!).Enabled = True

End With

Bon courage
Avatar
papou
Bonjour
Bon courage
Je réitère !


Cordialement
Pascal

"" @discussions.microsoft.com> a
écrit dans le message de
news:
il ny a pas d'astuce mais des programmes VBA pour pouvoir interdire le
copier-coller sont nombreux.

Le nombre d'instructions à passer est important car le nombre de manières
de copier-coller sous Excel est très riche. Je t'indique une manière parmi

d'autres.
Il te faut placer ce code dans le module Thisworkbook dans la proédure
évenementielle Open


On Error Resume Next
With Application
'disables shortcut keys
.OnKey "^c", ""
.OnKey "^v", ""
.OnKey "^x", ""
'Disables Copy
.CommandBars("Edit").FindControl(ID:).Enabled = False
.CommandBars("Edit").FindControl(ID:„8).Enabled = False
.CommandBars("Cell").FindControl(ID:).Enabled = False
.CommandBars("Column").FindControl(ID:).Enabled = False
.CommandBars("Row").FindControl(ID:).Enabled = False
.CommandBars("Button").FindControl(ID:).Enabled = False
.CommandBars("Formula Bar").FindControl(ID:).Enabled = False
.CommandBars("Worksheet Menu Bar").FindControl(ID:).Enabled = False
.CommandBars("Standard").FindControl(ID:).Enabled = False
.CommandBars("Button").FindControl(ID:„8).Enabled = False
.CommandBars("Formula Bar").FindControl(ID:„8).Enabled = False
.CommandBars("Worksheet Menu Bar").FindControl(ID:„8).Enabled False
.CommandBars("Standard").FindControl(ID:„8).Enabled = False
.CommandBars("Ply").FindControl(ID:„8).Enabled = False
'Disables Cut
.CommandBars("Edit").FindControl(ID:!).Enabled = False
.CommandBars("Cell").FindControl(ID:!).Enabled = False
.CommandBars("Column").FindControl(ID:!).Enabled = False
.CommandBars("Row").FindControl(ID:!).Enabled = False
.CommandBars("Button").FindControl(ID:!).Enabled = False
.CommandBars("Formula Bar").FindControl(ID:!).Enabled = False
.CommandBars("Worksheet Menu Bar").FindControl(ID:!).Enabled = False
.CommandBars("Standard").FindControl(ID:!).Enabled = False

End With

si tu veux rétablir les commandes mettre dans la procdure evenenmentielle
before close de THisworkbook les commandes suivantes


On Error Resume Next
With Application
.OnKey "^c"
.OnKey "^v"
.OnKey "^x"

'Enables Copy
.CommandBars("Edit").FindControl(ID:).Enabled = True
.CommandBars("Edit").FindControl(ID:„8).Enabled = True
.CommandBars("Cell").FindControl(ID:).Enabled = True
.CommandBars("Column").FindControl(ID:).Enabled = True
.CommandBars("Row").FindControl(ID:).Enabled = True
.CommandBars("Button").FindControl(ID:).Enabled = True
.CommandBars("Formula Bar").FindControl(ID:).Enabled = True
.CommandBars("Worksheet Menu Bar").FindControl(ID:).Enabled = True
.CommandBars("Standard").FindControl(ID:).Enabled = True
.CommandBars("Button").FindControl(ID:„8).Enabled = True
.CommandBars("Formula Bar").FindControl(ID:„8).Enabled = True
.CommandBars("Worksheet Menu Bar").FindControl(ID:„8).Enabled = True
.CommandBars("Standard").FindControl(ID:„8).Enabled = True
.CommandBars("Ply").FindControl(ID:„8).Enabled = True
' Enables Cut
.CommandBars("Edit").FindControl(ID:!).Enabled = True
.CommandBars("Cell").FindControl(ID:!).Enabled = True
.CommandBars("Column").FindControl(ID:!).Enabled = True
.CommandBars("Row").FindControl(ID:!).Enabled = True
.CommandBars("Button").FindControl(ID:!).Enabled = True
.CommandBars("Formula Bar").FindControl(ID:!).Enabled = True
.CommandBars("Worksheet Menu Bar").FindControl(ID:!).Enabled = True
.CommandBars("Standard").FindControl(ID:!).Enabled = True

End With

Bon courage






Avatar
michdenis
Bonjour loadmaster,


Si par copier-coller, tu signifies dans le même classeur, tu peux essayer ceci. Ces lignes de code vont désactiver le
copier-coller dans tout le classeur .... mais tu pourrais toujours effectuer un copier-coller vers un autre classeur ou
une autre application. Au besoin, il y a moyen de limiter ceci à une feuille particulière.

Dans le thisworkbook de ton projet :

'----------------------
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)

Application.CutCopyMode = False

End Sub
'----------------------


Salutations!



"loadmaster" a écrit dans le message de
news:
Y-a-t-il une astuce pour empecher un copier/coller de cellules non protegées dans une feuille protegée

Mci et slts
Avatar
loadmaster
Merci à tous mais j'ai retenu et mis en application la réponse de michdenis car elle était la plus simple à rédiger et en plus la mieux adaptée car cela ne concerne que trois classeurs comprenant des centrages avions pour lesquels je voulais interdire tout deplacement de formule par un copier/coller.

Merci et slts
Michel


"michdenis" wrote:

Bonjour loadmaster,


Si par copier-coller, tu signifies dans le même classeur, tu peux essayer ceci. Ces lignes de code vont désactiver le
copier-coller dans tout le classeur .... mais tu pourrais toujours effectuer un copier-coller vers un autre classeur ou
une autre application. Au besoin, il y a moyen de limiter ceci à une feuille particulière.

Dans le thisworkbook de ton projet :

'----------------------
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)

Application.CutCopyMode = False

End Sub
'----------------------


Salutations!



"loadmaster" a écrit dans le message de
news:
Y-a-t-il une astuce pour empecher un copier/coller de cellules non protegées dans une feuille protegée

Mci et slts