prompt message

I want to create a program that will prompt me a message when my filewas open, say example myFile.doc. It will prompt me "myFile.doc was open".And if myFile.doc will be close it will prompt me again a message. "myFile.doc was close". Any help are very much appreciated.