Macro run automatically when open a file

Hi guys,

Do you know how to call a macro automatically (without a button)when you open a drawing, another when you open a part and samethingfor the close events ?

Thanks,
SolidworksApi macros