When my sunroof is in the closed position it sags at the back end, and one corner sags more than the other. Every fix I've seen involves removing the sunroof liner panel, loosening the bolts on the panel, then re-tightening them after slightly adjusting the panel. This isn't difficult, but it didn't make sense that this was the correct way to adjust it.

There are no sensors on the actual panel or mechanism that detect where the sunroof is along its travel, it's all in the motor cam gear stop points. The motor movement is also continuous from fully open to fully tilted (closed is just a position along the way from open to tilt). The motor gear drives two screw cables: one for each side of the sunroof. What I did was close the sunroof, then use the hex tool from the tool kit to manually drive the motor until the back of the sunroof was at the correct height (one corner was flush the other was too high). Next unbolt the motor, then slide the screw drive (using a flat blade screwdriver) for the side that is too high until it is also flush (you only need to do this if your sunroof wasn't even on both sides). Before bolting the motor back in place hit the switch to close the sunroof so that the motor is reset back to closed position. Enjoy your fixed sunroof
Written by m60power, Cars e34 540, e32 740il