jackypirate
Messages postés
3
Date d'inscription
vendredi 21 novembre 2008
Statut
Membre
Dernière intervention
16 décembre 2008
16 déc. 2008 à 11:06
Salut
Je reviens à mon problème, qui n'ai toujours pas résolut. J'ai testé les deux codes sans résultat (code de Bigfish_le vrai et de Orohena merci encore à vous 2).
Pour faire plus facile j'ai copié le code dans lequel j'aimerais intégrer une barre de progression, ce code se déroule en 5 étapes.
1_ copie des données graphiques
2_création de la nouvelle semaine
3_éffacement des données
4_sauvegarde sur le server (lecteur partagé N)
5_fermeture de la semaine
Sub Transfert_Données()
ChDir Application.DefaultFilePath + "\Relevés consommables"
Workbooks.Open Filename:="Relevé conso sem_0.xls"
ActiveSheet.Unprotect
ActiveWindow.ActivateNext
Données_graphique
Sheets("Graphique conso").Select
Données_graph = Range("A8:S60")
Sheets("Consommables").Select
Données_conso = Range("H8:H24")
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
ActiveWindow.ActivateNext
ActiveWindow.ActivateNext
Sheets("Graphique conso").Select
ActiveSheet.Unprotect
Range("A8:S60") = Données_graph
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Sheets("Consommables").Select
Range("F8:F24") = Données_conso
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Range("C1").Select
ActiveWorkbook.Save
ActiveWorkbook.Close
Range("C1").Select
Création_Semaine
Effacer_Données
Sauvegarde_sur_N
Fermer_Semaine
End Sub
'GESTION DE LA BOITE DE DIALOGUE CREATION SEMAINE
Sub Création_Semaine()
Application.ScreenUpdating = False
UserForm1.Show
End Sub
'GESTION DE LA BOITE DE DIALOGUE CREATION SEMAINE
Sub Créer_Semaine()
Semaine = UserForm1.ComboBox2.Value
Annee = UserForm1.ComboBox3.Value
selectionsemaine = Format$(Semaine, "00")
selectionannee = Format$(Annee, "0000")
UserForm1.Hide
nomfichSEMAINE = "Relevé consommables" & "-" & "Sem" & Format$(Semaine, "00") & "-" & Format$(Annee, "0000") & ".xls"
On Error GoTo PasDeFiche
ChDir Application.DefaultFilePath + "\Relevés consommables" + "\Semaine" + "\Année" & " " & Format$(Annee, "0000")
Workbooks.Open Filename:=nomfichSEMAINE
MsgBox ("Le classeur que vous voulez créer existe déjà")
Application.DisplayAlerts = False
ActiveWorkbook.Close
Création_Semaine
Exit Sub
PasDeFiche:
ChDir Application.DefaultFilePath + "\Relevés consommables"
Workbooks.Open Filename:="Relevé conso sem_0.xls"
Windows("Relevé conso sem_0.xls").Activate
ActiveSheet.Unprotect
Cells(1, 3) = Format$(Semaine, "00")
Cells(1, 4) = Format$(Annee, "0000")
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Application.ScreenUpdating = False
Application.DisplayAlerts = False
ChDir Application.DefaultFilePath + "\Relevés consommables" + "\Semaine" + "\Année" & " " & Format$(Annee, "0000")
ActiveWorkbook.SaveCopyAs nomfichSEMAINE
Windows("Relevé conso sem_0.xls").Activate
Sheets("Consommables").Select
ActiveSheet.Unprotect
Cells(1, 4) = ""
Cells(1, 3) = ""
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
ActiveWorkbook.Save
ActiveWorkbook.Close
End Sub
Sub Effacer_Données()
ChDir Application.DefaultFilePath + "\Relevés consommables"
Workbooks.Open Filename:="Relevé conso sem_0.xls"
ActiveSheet.Unprotect
Sheets("Consommables").Select
Range("F8:F25").Select
Selection.ClearContents
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Range("C1").Select
ActiveWorkbook.Save
ActiveWorkbook.Close
End Sub
Sub Sauvegarde_sur_N()
ActiveWorkbook.Protect "8973", Structure:=False, Windows:=False
On Error GoTo LecteurRéseauPasConnecté
ChDir "N:\ECHANGES\Trait_Donnees_CDTK2"
Workbooks.Open Filename:="N:\ECHANGES\Trait_Donnees_CDTK2\Bilan_Conso_Hebdo56.xls"
ActiveWorkbook.Protect "8973", Structure:=False, Windows:=False
ActiveWindow.ActivateNext
Sheets("Consommables").Select
ActiveSheet.Unprotect
Sheets("Consommables").Copy Before:=Workbooks("Bilan_Conso_Hebdo56.xls").Sheets(1)
On Error GoTo LaFeuilleExisteDéjà
Sheets("Consommables").Name = "sem" & " " & Cells(1, 3) & "-" & Cells(1, 4)
Worksheets("sem" & " " & Cells(1, 3) - 2 & "-" & Cells(1, 4)).Delete
ActiveWindow.Zoom = 85
With ActiveWindow
.DisplayHorizontalScrollBar = False
.DisplayVerticalScrollBar = False
.DisplayWorkbookTabs = True
End With
Range("B1:D1").Select
Selection.Copy
Range("B5:D5").Select
ActiveSheet.Paste
Rows("1:2").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlUp
Range("C3").Select
ActiveWorkbook.Protect "8973", Structure:=True, Windows:=False
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
ActiveWorkbook.Save
ActiveWindow.Close
Exit Sub
LaFeuilleExisteDéjà:
Application.DisplayAlerts = False
Worksheets("sem" & " " & Cells(1, 3) & "-" & Cells(1, 4)).Delete
Worksheets("sem" & " " & Cells(1, 3) - 2 & "-" & Cells(1, 4)).Delete
Sheets("Consommables").Name = "sem" & " " & Cells(1, 3) & "-" & Cells(1, 4)
ActiveWindow.Zoom = 85
With ActiveWindow
.DisplayHorizontalScrollBar = False
.DisplayVerticalScrollBar = False
.DisplayWorkbookTabs = True
End With
Range("B1:D1").Select
Selection.Copy
Range("B5:D5").Select
ActiveSheet.Paste
Rows("1:2").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlUp
Range("C3").Select
ActiveWorkbook.Protect "8973", Structure:=True, Windows:=False
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
ActiveWorkbook.Save
ActiveWindow.Close
Exit Sub
LecteurRéseauPasConnecté: Select Case MsgBox("Voulez-vous vous connecter au lecteur réseau N. Login KI00087 - Mot de passe K2pl56018", vbYesNo)
Case vbYes
MyAppID = Shell("D:\LOCAL\PLUS_IBD\NewLogin\LoginBK")
Sauvegarde_sur_N
Case vbNo
ActiveWorkbook.Protect "8973", Structure:=True, Windows:=False
ActiveWorkbook.Save
End Select
End Sub
'Fermeture semaine active
Sub Fermer_Semaine()
ActiveWorkbook.Protect "8973", Structure:=False
Application.ScreenUpdating = False
Application.CommandBars("Barre d'outils 56").Visible = True
Application.CommandBars("Barre d'outils conso").Visible = False
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
ActiveWorkbook.Protect "8973", Structure:=True
ActiveWindow.Close SaveChanges:=True
End Sub