timetrack-pro/final_cleanup.vbs
StillHammer 7c3dd3fb31 Add VBS scripts, documentation, and HTML form templates
- 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>
2026-01-21 11:53:09 +07:00

82 lines
2.2 KiB
Plaintext

On Error Resume Next
Dim accessApp
Set accessApp = CreateObject("Access.Application")
accessApp.OpenCurrentDatabase "C:\Users\alexi\Documents\projects\timetrack-pro\db\TimeTrackPro.accdb"
WScript.Echo "=== Final cleanup: Direct VBProject manipulation ==="
Dim vbProj
Set vbProj = accessApp.VBE.VBProjects(1)
' List all components first
WScript.Echo ""
WScript.Echo "Before cleanup:"
Dim c
For Each c In vbProj.VBComponents
If Left(c.Name, 4) = "OLD_" Or Left(c.Name, 5) = "Form_" Then
WScript.Echo " " & c.Name & " (Type " & c.Type & ")"
End If
Next
' Try to delete OLD modules one by one
WScript.Echo ""
WScript.Echo "Attempting removal..."
Dim oldModules
oldModules = Array("OLD_Form_frm_Accueil", "OLD_Form_frm_Clients", "OLD_Form_frm_Projets", "OLD_Form_frm_Historique")
Dim i, comp
For i = 0 To UBound(oldModules)
WScript.Echo "Looking for: " & oldModules(i)
Dim removed
removed = False
On Error Resume Next
' Try multiple times if needed
Dim attempts
For attempts = 1 To 5
For Each comp In vbProj.VBComponents
If comp.Name = oldModules(i) Then
vbProj.VBComponents.Remove comp
If Err.Number = 0 Then
WScript.Echo " Removed on attempt " & attempts
removed = True
Exit For
End If
End If
Next
If removed Then Exit For
Next
If Not removed Then
WScript.Echo " Could not remove (will try renaming instead)"
' Try renaming
For Each comp In vbProj.VBComponents
If comp.Name = oldModules(i) Then
On Error Resume Next
comp.Name = "DELETED_" & oldModules(i)
WScript.Echo " Renamed to: DELETED_" & oldModules(i)
Exit For
End If
Next
End If
Next
WScript.Echo ""
WScript.Echo "After cleanup:"
For Each c In vbProj.VBComponents
If Left(c.Name, 4) = "OLD_" Or Left(c.Name, 5) = "Form_" Or Left(c.Name, 8) = "DELETED_" Then
WScript.Echo " " & c.Name & " (Type " & c.Type & ")"
End If
Next
accessApp.CloseCurrentDatabase
accessApp.Quit
Set accessApp = Nothing
WScript.Echo ""
WScript.Echo "Done!"