Is it possible to automatically invoke a given applescript when opening -any- document with a given application?

In effect, I would like to automatically detect the "open file" operation (irrespective of how the file was opened) so as to immediately follow it with a specific AS.

I would similarly like to automatically precede any "close file" operation with another AS.

Is this possible via Automator or some other way?