I've done it with my 1990 300SE. It's a fairly easy swap with the gen II cars, you will need all the parts from the W140, including the seal. The W126 seal isn't air tight enough with the glass panel, awful wind noise above 35mph. Got a new seal from the dealer, $140
It's possible with the earlier W126 and even the W116 models, but you have to swap out the entire capsule, much bigger job.
Kent Bergsma has a couple of excellent videos on his website about how to maintain the sunroof, troubleshoot and adjust them. Well worth the cost.