Dan, surely you've haunted these forums long enough to recognise the (get-active-document) & (get-acad-object) routines from Mark & Se7en & company. I always forget... are those routines yours Mark ?
if you do a search here or at cadalog, you'll find them easily enough.