Try the following as a replacement of your OpenDwgFile routine:
Code:
(defun OpenDwgFile (arg1 / )
(vla-activate (vla-open (vla-get-documents (vlax-get-acad-object)) arg1))
); defun
Note that I have removed arg2. As long as the routine is trying to return a value (i.e. vlax-true or vlax-false) it will continue running after the new drawing is opened, and this will serve to keep focus from shifting to the new drawing. Also, I am unsure of its purpose in any case, as it only tells OpenDwgFile to return what you want it to return.
Note that
Code:
(OpenDwgFile stDetailName nil)
Will need to be replaced by
Code:
(OpenDwgFile stDetailName)
in C:DETLOPEN
I hope this proves helpful.