Can I run a Solidworks Macro during a state change?

I'm trying to figure out how to run a Solidworks macro during a state change?  Any ideas?

SolidworksSolidworks Pdm enterprise Pdm