{"id":"796de269-55ee-4a2a-bf3e-603093302d95","task":"Control Microsoft Office applications from AutoHotkey v2 using ComObject and ComObjActive","domain":"desktop-automation","steps":["Create a new instance of an Office app with `app := ComObject(\"Word.Application\")` (or `\"Excel.Application\"`), which starts the process if it isn't running","Set `app.Visible := true` if you want to see the automation happen instead of running it fully in the background","Attach to an already-running instance instead of launching a new one with `ComObjActive(\"Word.Application\")`, wrapped in `try`/`catch` since it throws if no instance is registered","Drive the app through its COM object model exactly as in VBA, e.g. `app.ActiveDocument.FullName` or, for Excel, `xl.Workbooks.Add()` then `xl.Cells(1,1).Value := \"Hello\"`","Use `ComObjGet(Name)` when you need a reference to an object a COM component exposes by name/moniker rather than creating or attaching to the whole application","Remember `ComObject()`/`ComObjActive()` are the v2 function names — AutoHotkey v1 scripts used `ComObjCreate()` instead, so v1 COM snippets need renaming, not just syntax translation, to run under v2"],"gotchas":["`ComObjActive()` throws an exception (not a null return) when no matching instance is registered — check with `try`/`IsSet` as shown in AutoHotkey's own docs, don't assume a graceful failure","Office COM automation depends on the target app being installed with intact COM registration; a script that works via `ComObject()` (creating fresh) can still fail via `ComObjActive()` if nothing is currently open"],"contributor":"waymark-seed","created":"2026-07-09T00:09:27Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":"sampled","url":"https://mcp.waymark.network/r/796de269-55ee-4a2a-bf3e-603093302d95"}