Bonjour à tous,
J'ai, dans mon fichier Excel, des commandes boutons pour imprimer des zones d'impressions. Quand je clique sur le bouton, Excel mouline, ferme et se réouvre. Je n'ai aucunes idées pourquoi ça ne fonctionne pas, alors que ça marchait très bien avant.
Précision : même faire CTRL+P sur n'importe quelle feuille/cellule/données/Etc fait "planter" le logiciel.
Je vous joint mon fichier, ainsi que le code.
J'ai, dans mon fichier Excel, des commandes boutons pour imprimer des zones d'impressions. Quand je clique sur le bouton, Excel mouline, ferme et se réouvre. Je n'ai aucunes idées pourquoi ça ne fonctionne pas, alors que ça marchait très bien avant.
Précision : même faire CTRL+P sur n'importe quelle feuille/cellule/données/Etc fait "planter" le logiciel.
Je vous joint mon fichier, ainsi que le code.
VB:
Private Sub Workbook_Open()
Application.ScreenUpdating = False
Sheets("MENU PRINCIPAL").Activate
For i = 1 To 7
Sheets("MAGASIN " & i).Visible = xlSheetHidden
Next
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call remise_a_zero
ActiveWorkbook.Save
End Sub
Sub redirection_mag()
Application.ScreenUpdating = False
Dim choix_mag As String
Dim num_anomalie As Integer
num_anomalie = Range("A2").Value
num_anomalie = num_anomalie + 1
Range("A2") = num_anomalie
choix_mag = Range("A1")
Sheets(choix_mag).Visible = xlSheetVisible
Sheets(choix_mag).Select
ActiveSheet.Unprotect
Range("C4") = num_anomalie
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub
Sub retour_accueil()
Sheets("MENU PRINCIPAL").Select
End Sub
Sub GoTo_decla_fiche()
Sheets("FICHE DE DECLARATION").Select
End Sub
Sub impression_parent()
Dim val As Integer
val = Range("C4").Value
If val <> 0 Then
ActiveSheet.PageSetup.PrintArea = "A1:D33"
ActiveSheet.PrintOut
Else
MsgBox "NUMÉRO D'ANOMALIE NON DETECTÉ, REVENIR AU MENU PRINCIPAL ET RELANCER LA DÉCLARATION MANQUANT", vbOKCancel + vbCritical, "ERREUR"
End If
End Sub
Sub impression_enfant()
Dim val As Integer
val = Range("M4").Value
If val <> 0 Then
ActiveSheet.PageSetup.PrintArea = "K1:N33"
ActiveSheet.PrintOut
Else
MsgBox "VEUILLEZ INDIQUER UN NUMÉRO D'ANOMALIE", vbOKCancel + vbExclamation, "ERREUR"
End If
End Sub
Sub impression_decla()
Dim val As Integer
val = Range("C9").Value
If val <> 0 Then
ActiveSheet.PageSetup.PrintArea = "A1:D32"
ActiveSheet.PrintOut
Else
MsgBox "VEUILLEZ INDIQUER UN NUMÉRO D'ANOMALIE", vbOKCancel + vbExclamation, "ERREUR"
End If
End Sub
Sub remise_a_zero()
Application.ScreenUpdating = False
Dim i As Integer
'RaZ fiche décla
Sheets("FICHE DE DECLARATION").Activate
Range("B6:B7").Select
Selection.ClearContents
Range("D6:D7").Select
Selection.ClearContents
Range("C8:D8").Select
Selection.ClearContents
Range("C9:D9").Select
Selection.ClearContents
Range("A12:D26").Select
Selection.ClearContents
Range("C28:D28").Select
Selection.ClearContents
Range("B30:D32").Select
Selection.ClearContents
'RaZ magasins
For i = 1 To 7
Sheets("MAGASIN " & i).Activate
Range("A9:D33").Select
Selection.ClearContents
Range("K9:N33").Select
Selection.ClearContents
Range("m4").Select
Selection.ClearContents
Next
End Sub