I found a TSB on the issue your having. Here it is, and how to correct it, easier than me trying to explain it to you. let me know how it goes.
Bulletin No.: 03-08-67-009A
Date: March 08, 2004
Subject:Sunroof Will Not Open or Close Completely (Replace Sunroof Motor)
Models:1998-2004 Chevrolet Cavalier1999-2003 Oldsmobile Alero1998-2003 Pontiac Grand Am1998-2004 Pontiac Sunfire
This bulletin is being revised to change the part number. Please discard Corporate Bulletin Number 03-08-67-009 (Section 08 - Body and Accessories)
Some customers may comment that the sunroof will not open or will not close completely.
This condition may be due to the sunroof motor. Follow the procedure below for diagnostics.
Sunroof Motor Diagnosis
Sunroof Motor Replacement
Note: This sunroof system is timed from the factory so that the sunroof actuator automatically shuts off when the window panel reaches a certain position. Be careful not to disrupt this factory timing when removing the sunroof actuator from the sunroof module. Disrupting the factory timing may cause damage to the sunroof system. Close the window panel whenever you remove the sunroof actuator from the sunroof module assembly.
Tighten the sunroof motor/actuator to 3 N.m (27 lb in).
Parts are currently available from GMSPO.
For vehicles repaired under warranty, use the table.