- 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>
49 lines
1.6 KiB
Plaintext
49 lines
1.6 KiB
Plaintext
Dim accessApp
|
|
Set accessApp = CreateObject("Access.Application")
|
|
|
|
accessApp.OpenCurrentDatabase "C:\Users\alexi\Documents\projects\timetrack-pro\db\TimeTrackPro.accdb"
|
|
|
|
' Execute VBA code to enable modules using DAO
|
|
Dim vbaCode
|
|
vbaCode = "Public Sub EnableModules()" & vbCrLf & _
|
|
"Dim db As DAO.Database" & vbCrLf & _
|
|
"Set db = CurrentDb" & vbCrLf & _
|
|
"Dim doc As DAO.Document" & vbCrLf & _
|
|
"Dim formNames As Variant" & vbCrLf & _
|
|
"formNames = Array(""frm_Accueil"", ""frm_Clients"", ""frm_Projets"", ""frm_SaisieTemps"", ""frm_Historique"")" & vbCrLf & _
|
|
"Dim i As Integer" & vbCrLf & _
|
|
"For i = LBound(formNames) To UBound(formNames)" & vbCrLf & _
|
|
" Set doc = db.Containers(""Forms"").Documents(formNames(i))" & vbCrLf & _
|
|
" doc.Properties(""HasModule"") = True" & vbCrLf & _
|
|
" Debug.Print ""Enabled: "" & formNames(i)" & vbCrLf & _
|
|
"Next i" & vbCrLf & _
|
|
"MsgBox ""All modules enabled!""" & vbCrLf & _
|
|
"End Sub"
|
|
|
|
' Add temp module
|
|
On Error Resume Next
|
|
accessApp.DoCmd.DeleteObject 5, "tempModuleEnabler" ' 5 = acModule
|
|
Err.Clear
|
|
|
|
Dim vbProj
|
|
Set vbProj = accessApp.VBE.VBProjects(1)
|
|
Dim vbComp
|
|
Set vbComp = vbProj.VBComponents.Add(1) ' 1 = vbext_ct_StdModule
|
|
vbComp.Name = "tempModuleEnabler"
|
|
vbComp.CodeModule.AddFromString vbaCode
|
|
|
|
WScript.Sleep 1000
|
|
|
|
' Run the macro
|
|
accessApp.Run "tempModuleEnabler.EnableModules"
|
|
|
|
WScript.Sleep 1000
|
|
|
|
' Cleanup
|
|
accessApp.DoCmd.DeleteObject 5, "tempModuleEnabler"
|
|
|
|
accessApp.CloseCurrentDatabase
|
|
accessApp.Quit
|
|
|
|
WScript.Echo "Done!"
|