Are you looking to do something like this? http://www.youtube.com/watch?v=y01TTpgufkY Then search Solidworks Help for animation.
Deepak recently had a blog post about motion along a path ( Could be a path for a sunroof ) http://gupta9665.wordpress.com/2010/07/01/motion-along-path/
Hope that helps,
You may try using a "path mate" to control the motion, you will find it in the mate tool under the "advanced mates" group box.
From the help menu:
"A Path mate constrains a selected point on a component to a path. You define the path by selecting one or more entities in the assembly. You can define pitch, yaw, and roll of the component as it travels along the path."
Typically I add a point in the part I want to follow the path and then skecth the path in the assembly using a 2D or 3D sketch depending on the motion desired.