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 10/02/2012, 09h36   #1
Candidat au titre de Membre du Club
 
Inscription : juin 2011
Messages : 122
Détails du profil
Informations forums :
Inscription : juin 2011
Messages : 122
Points : 13
Points : 13
Par défaut Problème avec code placé dans "ThisWorkbook"

Bonjour.

Je rencontre un problème avec ce code que j'ai placé dans la feuille "ThisWorkbook" d'un classeur.
Lorsque j'ai plusieurs classeurs d'ouverts, le code est appliqué à l'ensemble des classeurs et pas simplement celui dans lequel il est placé.
Comment dois-je faire SVP pour qu'il ne fonctionne que dans celui que je souhaite sans m'empêcher de travailler avec les autres classeurs?
Quelle ligne de code dois je également ajouter pour interdire l'accès au option EXCEL du bouton démarrer?

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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
With Application
.OnKey "^c"
.OnKey "^v"
.OnKey "^x"
 
'Enables 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
 'Enables 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
Application.Calculation = xlCalculationAutomatic
Application.ActiveWindow.DisplayWorkbookTabs = True
 
End Sub
 
Private Sub Workbook_Open()
Sheets("Gestion bobine").Select
Range("A1").Select
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
Application.ActiveWindow.DisplayWorkbookTabs = False
 
End Sub
Fred4345 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 10/02/2012, 10h01   #2
Membre habitué
 
Homme Michael
Ingénieur qualité méthodes
Inscription : octobre 2010
Messages : 200
Détails du profil
Informations personnelles :
Nom : Homme Michael
Localisation : France, Aisne (Picardie)

Informations professionnelles :
Activité : Ingénieur qualité méthodes
Secteur : Industrie

Informations forums :
Inscription : octobre 2010
Messages : 200
Points : 115
Points : 115
Bonjour,

Remplace:
par

Code :
With Application.Workbooks("Nom") 'Remplace Nom par le nom de ton fichier
je pense que ce sera bon ^^ mais à voir ^^
redstoff est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 10/02/2012, 11h12   #3
Candidat au titre de Membre du Club
 
Inscription : juin 2011
Messages : 122
Détails du profil
Informations forums :
Inscription : juin 2011
Messages : 122
Points : 13
Points : 13
Merci pour ton aide! Cela fonctionne correctement maintenant.
As tu une idée pour ma deuxième question ? Interdire l'ouverture des options Excel dans le bouton office.
Fred4345 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 10/02/2012, 13h36   #4
Membre habitué
 
Homme Michael
Ingénieur qualité méthodes
Inscription : octobre 2010
Messages : 200
Détails du profil
Informations personnelles :
Nom : Homme Michael
Localisation : France, Aisne (Picardie)

Informations professionnelles :
Activité : Ingénieur qualité méthodes
Secteur : Industrie

Informations forums :
Inscription : octobre 2010
Messages : 200
Points : 115
Points : 115
bloquer je ne sais pas mais une fois j'ai contré ca en lancant le mode plein ecran au demarrage comme ca les Options ne sont pas accessible

utilise la commande dans le workbook_open

Code :
1
2
Application.DisplayFullScreen = True
    Application.DisplayFullScreen = False
et pour améliorer tu peux faire

Code :
1
2
3
4
Private Sub Workbook_Open()
    Application.DisplayFullScreen = True
    Application.OnKey "{ESC}", "PleinEcran"
End Sub
et dans un module standart

Code :
1
2
3
Sub PleinEcran()
    Application.DisplayFullScreen = True
End Sub
comme ca si quelqu'un appuis sur Echap pour quitter le plein ecran il le remet automatiquement.
enfin c'est dans mon exemple apres a toi de choisir ce que tu veux que ca fasse^^.
redstoff est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 12/02/2012, 14h44   #5
Candidat au titre de Membre du Club
 
Inscription : juin 2011
Messages : 122
Détails du profil
Informations forums :
Inscription : juin 2011
Messages : 122
Points : 13
Points : 13
Une fois en mode plein écran comment fais-tu si tu as besoin pour revenir en mode affichage normale?
En mode plein écran la barre de formule disparaît également. Comment la garder?
Fred4345 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 15/02/2012, 17h41   #6
Candidat au titre de Membre du Club
 
Inscription : juin 2011
Messages : 122
Détails du profil
Informations forums :
Inscription : juin 2011
Messages : 122
Points : 13
Points : 13
Je reviens vers le forum avec ma question. Quelqu'un a-t-il une idée pour interdire l'accès au option d'Excel à l'ouverture d'un classeur?
Fred4345 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 09h48.


 
 
 
 
Partenaires

Hébergement Web