- 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>
37 lines
860 B
Plaintext
37 lines
860 B
Plaintext
On Error Resume Next
|
|
|
|
Dim accessApp
|
|
Set accessApp = CreateObject("Access.Application")
|
|
|
|
Dim dbPath
|
|
dbPath = "C:\Users\alexi\Documents\projects\timetrack-pro\db\TimeTrackPro.accdb"
|
|
Dim tempPath
|
|
tempPath = "C:\Users\alexi\Documents\projects\timetrack-pro\db\TimeTrackPro_temp.accdb"
|
|
|
|
WScript.Echo "Compacting and repairing database..."
|
|
|
|
' Compact and repair
|
|
accessApp.CompactRepair dbPath, tempPath
|
|
|
|
If Err.Number = 0 Then
|
|
WScript.Echo "Success! Replacing original file..."
|
|
|
|
Dim fso
|
|
Set fso = CreateObject("Scripting.FileSystemObject")
|
|
|
|
' Delete original
|
|
If fso.FileExists(dbPath) Then
|
|
fso.DeleteFile dbPath
|
|
End If
|
|
|
|
' Rename temp to original
|
|
fso.MoveFile tempPath, dbPath
|
|
|
|
WScript.Echo "Database compacted and repaired!"
|
|
Else
|
|
WScript.Echo "Error: " & Err.Description
|
|
End If
|
|
|
|
accessApp.Quit
|
|
Set accessApp = Nothing
|