Assuming that you are talking about an E39 (year and model in the future, please) The sunroof does not need to be removed to replace the weatherstrip.
Sounds like you already have a clean surface (new paint), start the new weatherstrip half way through the rear opening in the sunroof hole, I just exposed enough of the adhesive to get through the side that I was working on. Work through all of the sides individually, then when you get to the end where you meet up with the first piece of strip that you laid down you will have to carefully trim the seal, scissors would be better than a blade for this cut, leaving the adhesive unexposed for that side, trim the seal (erring on leaving it too long at first) and test fit, repeat until its a perfect fit, expose the adhesive and attach the seal like you did the rest of the sides.
I liberally applied some Armor All to the seal to reduce friction, and closed the roof so that the sunroof would apply even pressure to all sides of the new strip, and left it closed for overnight.
E39 - 1998 540iA Sport (11/97 Production)
E30 - 1989 M3 (44k miles)
1979 Triumph TR7, still have my first car ;-)
E21 - 1980 320i (sold at 130k)
E23 - 1986 735i
I am a BMW Car Club of America member, are you? <a href='http://www.bmwcca.org/' target='_blank'>http://www.bmwcca.org/</a>
<img src='http://members.roadfly.com/kowached/bmwcca1.gif' border='0' alt='user posted image'>