Modification du versionnage auto

This commit is contained in:
2026-05-10 16:12:23 +02:00
parent 703d2ecda3
commit c2b75076d0
57 changed files with 827 additions and 313 deletions

View File

@@ -1,68 +1,71 @@
' set_cell_silent.vbs
' Usage: cscript //nologo set_cell_silent.vbs "C:\chemin\fichier.xlsm" "NomFeuille" "A1" "Valeur"
Option Explicit
Dim f, sheetName, addr, val
Dim xl, wb, ws
Dim xl, wb
Dim filePath, sheetName, cellAddress, cellValue
If WScript.Arguments.Count < 4 Then
WScript.Echo "[ERR] Args: set_cell_silent.vbs <fichier.xlsm> <feuille> <cellule> <valeur>"
WScript.Quit 1
WScript.Echo "[ERR] Usage : set_cell_silent.vbs fichier.xlsm feuille cellule valeur"
WScript.Quit 1
End If
f = WScript.Arguments(0)
filePath = WScript.Arguments(0)
sheetName = WScript.Arguments(1)
addr = WScript.Arguments(2)
val = WScript.Arguments(3)
cellAddress = WScript.Arguments(2)
cellValue = WScript.Arguments(3)
On Error Resume Next
Set xl = CreateObject("Excel.Application")
If Err.Number <> 0 Then
WScript.Echo "[ERR] Excel non disponible (" & Err.Description & ")"
WScript.Quit 1
WScript.Echo "[ERR] Creation Excel : " & Err.Description
WScript.Quit 1
End If
On Error GoTo 0
xl.Visible = False
xl.DisplayAlerts = False
' Désactiver macros et événements AVANT douvrir
On Error Resume Next
xl.AutomationSecurity = 3 ' msoAutomationSecurityForceDisable
xl.EnableEvents = False
xl.ScreenUpdating = False
On Error GoTo 0
xl.AskToUpdateLinks = False
xl.AutomationSecurity = 3
Err.Clear
Set wb = xl.Workbooks.Open(filePath, 0, False)
On Error Resume Next
Set wb = xl.Workbooks.Open(f, False, False)
If Err.Number <> 0 Then
xl.Quit
WScript.Echo "[ERR] Ouverture classeur: " & Err.Description
WScript.Quit 1
WScript.Echo "[ERR] Ouverture classeur: " & Err.Description
xl.Quit
Set xl = Nothing
WScript.Quit 1
End If
On Error GoTo 0
On Error Resume Next
Set ws = wb.Worksheets.Item(sheetName)
Err.Clear
wb.Worksheets(sheetName).Range(cellAddress).Value = cellValue
If Err.Number <> 0 Then
wb.Close False
xl.Quit
WScript.Echo "[ERR] Feuille introuvable: " & sheetName
WScript.Quit 1
WScript.Echo "[ERR] Ecriture cellule: " & Err.Description
wb.Close False
xl.Quit
Set wb = Nothing
Set xl = Nothing
WScript.Quit 1
End If
On Error GoTo 0
On Error Resume Next
ws.Range(addr).Value2 = val
If Err.Number <> 0 Then
wb.Close False
xl.Quit
WScript.Echo "[ERR] Ecriture cellule " & addr & " : " & Err.Description
WScript.Quit 1
End If
On Error GoTo 0
Err.Clear
wb.Save
If Err.Number <> 0 Then
WScript.Echo "[ERR] Sauvegarde: " & Err.Description
wb.Close False
xl.Quit
Set wb = Nothing
Set xl = Nothing
WScript.Quit 1
End If
Err.Clear
wb.Close False
Set wb = Nothing
xl.Quit
WScript.Quit 0
Set xl = Nothing
WScript.Quit 0