I have a python script called from a VBA AutoNew() sub in a MS Word 2003 template (.dot) - so it runs every time a document is created from this Word template.
A thi
Some searching through the GitHub code of NVDA (Non-Visual Desktop Access) finally got me the object I was looking for:
#Part of the pywin32 package that must be installed with the pywin32
#installer:
import win32com.client as win32
import win32gui
from ctypes import oledll
from ctypes import byref
#installed by easy_install comtypes
from comtypes import POINTER
from comtypes.automation import IDispatch
import comtypes.client.dynamic as comDy
#Handle integer hwnds[0] per my edit in the question
OBJID_NATIVEOM = -16
p = POINTER(IDispatch)()
oledll.oleacc.AccessibleObjectFromWindow(hwnds[0], OBJID_NATIVEOM,
byref(IDispatch._iid_), byref(p))
window = comDy.Dispatch(p)
word = window.application
cert = word.Documents(1)