$ErrorActionPreference = "Stop" $basPath = "c:\Users\Alexei\Documents\VBA\MarathonStats.bas" $savePath = "c:\Users\Alexei\Documents\VBA\MarathonStats.xlsm" Write-Host "=== Marathon Stats Launcher ===" -ForegroundColor Cyan Write-Host "" Write-Host "[1/5] Starting Excel..." -ForegroundColor Yellow $excel = New-Object -ComObject Excel.Application $excel.Visible = $true $excel.DisplayAlerts = $false Write-Host "[2/5] Creating workbook..." -ForegroundColor Yellow $workbook = $excel.Workbooks.Add() Write-Host "[3/5] Importing VBA module..." -ForegroundColor Yellow try { $null = $workbook.VBProject.VBComponents.Import($basPath) Write-Host " Module imported OK" -ForegroundColor Green } catch { Write-Host "ERROR: Cannot access VBA project - $_" -ForegroundColor Red $excel.Quit() [System.Runtime.Interopservices.Marshal]::ReleaseComObject($excel) | Out-Null exit 1 } Write-Host "[4/5] Running FetchMarathonStats..." -ForegroundColor Yellow Write-Host " (curl will fetch page, then parse and format)" -ForegroundColor Gray try { $excel.Run("FetchMarathonStats") Write-Host " Macro completed" -ForegroundColor Green } catch { Write-Host " Macro error: $($_.Exception.Message)" -ForegroundColor Red } Write-Host "[5/5] Saving workbook..." -ForegroundColor Yellow try { if (Test-Path $savePath) { Remove-Item $savePath -Force } $workbook.SaveAs($savePath, 52) Write-Host " Saved to: $savePath" -ForegroundColor Green } catch { Write-Host " Save error: $($_.Exception.Message)" -ForegroundColor Red } Write-Host "" Write-Host "=== Done! ===" -ForegroundColor Cyan