- Test and helper VBS scripts for VBA MCP development - Technical reference documentation and PDFs - HTML form templates for all 5 forms - PowerShell and Python scripts for PDF/documentation generation Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
60 lines
1.6 KiB
Plaintext
60 lines
1.6 KiB
Plaintext
Dim accessApp
|
|
Set accessApp = CreateObject("Access.Application")
|
|
|
|
accessApp.OpenCurrentDatabase "C:\Users\alexi\Documents\projects\timetrack-pro\db\TimeTrackPro.accdb"
|
|
accessApp.Visible = True
|
|
|
|
Dim formNames
|
|
formNames = Array("frm_Accueil", "frm_Clients", "frm_Projets", "frm_SaisieTemps", "frm_Historique")
|
|
|
|
Dim i
|
|
For i = LBound(formNames) To UBound(formNames)
|
|
On Error Resume Next
|
|
|
|
' Ouvrir en mode Design
|
|
accessApp.DoCmd.OpenForm formNames(i), 2
|
|
WScript.Sleep 1000
|
|
|
|
' Acceder au module VBA du projet
|
|
Dim vbProj
|
|
Set vbProj = accessApp.VBE.VBProjects(1)
|
|
|
|
' Verifier si le module existe deja
|
|
Dim moduleExists
|
|
moduleExists = False
|
|
Dim comp
|
|
For Each comp In vbProj.VBComponents
|
|
If comp.Name = "Form_" & formNames(i) Then
|
|
moduleExists = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
|
|
If Not moduleExists Then
|
|
' Forcer la creation du module en ajoutant du code VBA
|
|
Dim vbComp
|
|
Set vbComp = vbProj.VBComponents.Add(100) ' 100 = vbext_ct_MSForm (form module)
|
|
vbComp.Name = "Form_" & formNames(i)
|
|
vbComp.CodeModule.AddFromString "Option Compare Database" & vbCrLf & "Option Explicit"
|
|
WScript.Echo "Created module for: " & formNames(i)
|
|
Else
|
|
WScript.Echo "Module already exists for: " & formNames(i)
|
|
End If
|
|
|
|
accessApp.DoCmd.Close 2, formNames(i), 1
|
|
|
|
If Err.Number = 0 Then
|
|
WScript.Echo "Module enabled for: " & formNames(i)
|
|
Else
|
|
WScript.Echo "Error for " & formNames(i) & ": " & Err.Description
|
|
Err.Clear
|
|
End If
|
|
Next
|
|
|
|
accessApp.CloseCurrentDatabase
|
|
accessApp.Quit
|
|
|
|
Set accessApp = Nothing
|
|
|
|
WScript.Echo "All done!"
|