Dim Xls, Classeur ,Fm ,Op
Op=true
const F="C:\Myrep\Prévision Stock TEST.xlsm"
On Error Resume Next
Set Xls = GetObject(, "Excel.application")
If Err <> 0 Then
Err.Clear
Op =False
Set Xls = CreateObject("Excel.application")
End If
On Error GoTo 0
Xls.visible=true
if IsOuvert(Xls,F)=false then
set Classeur= Xls.Workbooks.Open(F)
If Classeur.ReadOnly=false Then
TraitementSemaine Classeur
Classeur.save
Classeur.close false
if op=false then Xls.Quit
end if
end if
Function IsOuvert(Xls,F )
For Each C In Xls.Workbooks
IsOuvert = C.FullName = F
If IsOuvert Then Exit For
Next
End Function
Sub TraitementSemaine(Classeur)
If Weekday(Now) > 1 Then
Dim Jour: Jour = Array("", "Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi")
With Classeur.sheets(Jour(Weekday(Now)))
.select
With .Range("A1").CurrentRegion
.Range(.Cells(2, "F"), .Cells(.Rows.Count, "G")) = ""
.Range(.Cells(2, "J"), .Cells(.Rows.Count, "J")) = ""
.Range(.Cells(2, "O"), .Cells(.Rows.Count, "AZ")) = ""
End With
End With
End If
End Sub