Bonjour a tous,

voilà pour un classeur que je doit faire, j'ai eu besoin de bloquer la manoevre "Glisser/Déposer" et le "Copier/Coller".

Pour cela j'ai utilisé ces macros :

Pour le glisser déposer que j'ai pèlacé dans toutes les feuilles :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.CellDragAndDrop = True
End Sub
Pour le copier/coller, placé dans un module mais qui sont appeler au l'ouverture du classeur :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
Sub XCut()
On Error Resume Next
With Application
'disables shortcut keys
.OnKey "^c", ""
.OnKey "^v", ""
.OnKey "^x", ""
'Disables Copy
.CommandBars("Edit").FindControl(ID:=19).Enabled = False
.CommandBars("Edit").FindControl(ID:=848).Enabled = False
.CommandBars("Cell").FindControl(ID:=19).Enabled = False
.CommandBars("Column").FindControl(ID:=19).Enabled = False
.CommandBars("Row").FindControl(ID:=19).Enabled = False
.CommandBars("Button").FindControl(ID:=19).Enabled = False
.CommandBars("Formula Bar").FindControl(ID:=19).Enabled = False
.CommandBars("Worksheet Menu Bar").FindControl(ID:=19).Enabled = False
.CommandBars("Standard").FindControl(ID:=19).Enabled = False
.CommandBars("Button").FindControl(ID:=848).Enabled = False
.CommandBars("Formula Bar").FindControl(ID:=848).Enabled = False
.CommandBars("Worksheet Menu Bar").FindControl(ID:=848).Enabled = False
.CommandBars("Standard").FindControl(ID:=848).Enabled = False
.CommandBars("Ply").FindControl(ID:=848).Enabled = False
'Disables Cut
.CommandBars("Edit").FindControl(ID:=21).Enabled = False
.CommandBars("Cell").FindControl(ID:=21).Enabled = False
.CommandBars("Column").FindControl(ID:=21).Enabled = False
.CommandBars("Row").FindControl(ID:=21).Enabled = False
.CommandBars("Button").FindControl(ID:=21).Enabled = False
.CommandBars("Formula Bar").FindControl(ID:=21).Enabled = False
.CommandBars("Worksheet Menu Bar").FindControl(ID:=21).Enabled = False
.CommandBars("Standard").FindControl(ID:=21).Enabled = False
End With
End Sub
 
Sub VCut()
On Error Resume Next
With Application
'disables shortcut keys
.OnKey "^c", ""
.OnKey "^v", ""
.OnKey "^x", ""
'Disables Copy
.CommandBars("Edit").FindControl(ID:=19).Enabled = True
.CommandBars("Edit").FindControl(ID:=848).Enabled = True
.CommandBars("Cell").FindControl(ID:=19).Enabled = True
.CommandBars("Column").FindControl(ID:=19).Enabled = True
.CommandBars("Row").FindControl(ID:=19).Enabled = True
.CommandBars("Button").FindControl(ID:=19).Enabled = True
.CommandBars("Formula Bar").FindControl(ID:=19).Enabled = True
.CommandBars("Worksheet Menu Bar").FindControl(ID:=19).Enabled = True
.CommandBars("Standard").FindControl(ID:=19).Enabled = True
.CommandBars("Button").FindControl(ID:=848).Enabled = True
.CommandBars("Formula Bar").FindControl(ID:=848).Enabled = True
.CommandBars("Worksheet Menu Bar").FindControl(ID:=848).Enabled = True
.CommandBars("Standard").FindControl(ID:=848).Enabled = True
.CommandBars("Ply").FindControl(ID:=848).Enabled = True
'Disables Cut
.CommandBars("Edit").FindControl(ID:=21).Enabled = True
.CommandBars("Cell").FindControl(ID:=21).Enabled = True
.CommandBars("Column").FindControl(ID:=21).Enabled = True
.CommandBars("Row").FindControl(ID:=21).Enabled = True
.CommandBars("Button").FindControl(ID:=21).Enabled = True
.CommandBars("Formula Bar").FindControl(ID:=21).Enabled = True
.CommandBars("Worksheet Menu Bar").FindControl(ID:=21).Enabled = True
.CommandBars("Standard").FindControl(ID:=21).Enabled = True
End With
End Sub
Mais il semblerait que après avoir fermer le classeur ses macros s'appliquent également aux autres classeurs que j'ouvre.

Dès que j'ouvre un nouveau classeur ou un ancien classeur, le glisser/déposer est inutilisable, et le copier/coller est en partie inutilisable (Pas de collage spécial, et je n'arriveait pas a coller des lignes)

Ma question serait de savoir comment faire pour ne pas que la macro affecte les autes classeurs. Car se fichier excel doit être distribué, donc ça serait un peu une catastrophe

Merci a tous de votre attention