Ne pas afficher la boite d'alerte Impression sur excution macro

Résolu/Fermé
Gilles.DR315 Messages postés 26 Date d'inscription samedi 2 novembre 2013 Statut Membre Dernière intervention 27 janvier 2015 - 18 déc. 2013 à 20:28
eriiic Messages postés 24570 Date d'inscription mardi 11 septembre 2007 Statut Contributeur Dernière intervention 23 avril 2024 - 18 déc. 2013 à 22:19
Bonjour,

Je vous expose mon problème.

J'ai un tableau en Feuil1 ou une MsgBox s'affiche via :

Private Sub Worksheet_Activate()
Range("B16").Select
If Range("C1").Value = 2 Then Exit Sub
MsgBox ("........")
End Sub

Particularité : La feuil1 est masqué du classeur par défaut, et s'affiche sous condition.

Enfin J'ai une commande macro en "module 12" d'impression sélective.

Sub Impression()
If Range("G4").Value = "" Then Exit Sub
ThisWorkbook.Unprotect Password:="******"
With Worksheets("Feuil1")
.Visible = True
With .PageSetup
.PrintArea = "$B$12:$Y$311"
.PrintTitleRows = ""
.Orientation = xlPortrait
.FitToPagesWide = 1
.FitToPagesTall = 5
End With
.PrintOut
.Visible = False
End With
ThisWorkbook.Protect Password:="******"
End Sub

Question : est-il possible de lancer la macro d'impression sans tenir compte de la MsgBox où l'utilisateur doit confirmer par Ok. Il doit y avoir moyen de neutraliser la MsgBox

J'ai essayé d'introduire dans la macro :
Application.DisplayAlerts = False
(....)
Application.DisplayAlerts = True

Mais rien à faire. Ca ne marche pas.
Merci d'avance de votre aide et astuce.
Cdt

A voir également:

2 réponses

Gilles.DR315 Messages postés 26 Date d'inscription samedi 2 novembre 2013 Statut Membre Dernière intervention 27 janvier 2015 1
18 déc. 2013 à 21:51
J'ai trouvé la solution.

J'ai remplacé

Application.DisplayAlerts = False
par
Application.EnableEvents = False

Ca fonctionne

Sub Impression()
If Range("G4").Value = "" Then Exit Sub
ThisWorkbook.Unprotect Password:="******"
With Worksheets("Feuil1")
.Visible = True
Application.EnableEvents = False
With .PageSetup
.PrintArea = "$B$12:$Y$311"
.PrintTitleRows = ""
.Orientation = xlPortrait
.FitToPagesWide = 1
.FitToPagesTall = 5
End With
.PrintOut
.Visible = False
Application.EnableEvents = True
End With
ThisWorkbook.Protect Password:="******"
End Sub
1
eriiic Messages postés 24570 Date d'inscription mardi 11 septembre 2007 Statut Contributeur Dernière intervention 23 avril 2024 7 213
18 déc. 2013 à 22:19
Bonsoir,

J'ai modifié ton titre qui ne correspondait pas la demande, et mis en résolu pour toi (en haut vers ton titre pour la prochaine fois).
Sache que si tu joins un fichier les réponses son plus rapides, plus nombreuses, et surtout plus adaptées.

eric

0