Précédent   Forum des professionnels en informatique > Logiciels > Microsoft Office > Excel > Macros et VBA Excel
Macros et VBA Excel Vos questions relatives aux macros Excel, à l'utilisation de VBA et à l'automatisation de vos classeurs Excel.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 26/10/2011, 11h16   #1
 
Inscription : avril 2010
Messages : 1
Détails du profil
Informations forums :
Inscription : avril 2010
Messages : 1
Points : -1
Points : -1
Par défaut Copier/Couper Coller invalidé par macro que je ne sais pas annuler

Bonjour, j'ai un problème assez important. Voilà je travail avec excel sur des reporting que je dois envoyer à différentes structure. Et par crainte que les intervenant ne puissent pas modifier les classeurs j'ai téléchargé un code VBA qui annule les fonctions copier, couper et coller. Voici le code :

Code :
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
Private Sub Workbook_Desactivate()
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
 
'Disable Paste
.CommandBars("Edit").FindControl(ID:=22).Enabled = True
.CommandBars("Cell").FindControl(ID:=22).Enabled = True
.CommandBars("Column").FindControl(ID:=22).Enabled = True
.CommandBars("Row").FindControl(ID:=22).Enabled = True
.CommandBars("Button").FindControl(ID:=22).Enabled = True
.CommandBars("Formula Bar").FindControl(ID:=22).Enabled = True
.CommandBars("Worksheet Menu Bar").FindControl(ID:=22).Enabled = True
.CommandBars("Standard").FindControl(ID:=22).Enabled = True
 
'Disable PasteSpecial
.CommandBars("Edit").FindControl(ID:=755).Enabled = True
.CommandBars("Cell").FindControl(ID:=755).Enabled = True
.CommandBars("Column").FindControl(ID:=755).Enabled = True
.CommandBars("Row").FindControl(ID:=755).Enabled = True
.CommandBars("Button").FindControl(ID:=755).Enabled = True
.CommandBars("Formula Bar").FindControl(ID:=755).Enabled = True
.CommandBars("Worksheet Menu Bar").FindControl(ID:=755).Enabled = True
.CommandBars("Standard").FindControl(ID:=755).Enabled = True
End With
End Sub
L’éditeur du code a donné l'instruction de remplacer True par False pour que cette macro fonctionne. J'ai suivi ses instructions et j'ai envoyé une copie à un collègue pour voir si la fonction marche également dans son PC. On a remarqué que les fonctions copier couper coller ne marchent pas effectivement mais elle s'applique a tous les documents eXcel et Word et on a pas pu l'annuler (la rendre en l'état normal) SVP aidez moi je suis dans un gouffre? comment faire et merci d'avance
krreymou est déconnecté   Envoyer un message privé Réponse avec citation 01
Vieux 26/10/2011, 15h41   #2
Membre éclairé
 
Avatar de Nako_lito
 
Développeur .NET
Inscription : mai 2008
Messages : 561
Détails du profil
Informations professionnelles :
Activité : Développeur .NET

Informations forums :
Inscription : mai 2008
Messages : 561
Points : 390
Points : 390
Pourquoi ne pas générer des fichier PDF plutot que de désactiver toutes les fonctions ?
Excel a effectivement tendance a appliquer les changements de comportement a tous Excel, ce qui fait qu'on se retrouve avec quelque petits aléas.
__________________
- La dernière fois que j'ai testé ca fonctionnait !
- Vous n'avez rien modifié ?
- Non ! Je suis pas idiot non plus.
- ....
- Enfin si, juste le fichier .dll, mais a 4Ko, ca devait pas être important.
Nako_lito est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/10/2011, 22h23   #3
Membre Expert
 
Avatar de rtg57
 
Homme
Autodidacte
Inscription : mars 2006
Messages : 1 175
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Autodidacte
Secteur : Service public

Informations forums :
Inscription : mars 2006
Messages : 1 175
Points : 1 435
Points : 1 435
Bonjour,

ne serait-il pas possible de verrouiller le classeur ?
__________________
@ bientôt...

Salut & @+ sur 3W!
rtg57 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 08h51.


 
 
 
 
Partenaires

Hébergement Web