Vehicle: 2001 E320 - Brilliant Silver/Ash: MBCA member
Location: West Virginia, USA
Posts: 5,819
You might need to synchronize the sunroof. Why don't you be more specific and tell us whether the sunroof would not close without the battery in the car or after you replaced it? If the battery is now good you probably need to synchronize it with the system; the instructions are in the owner's guide. If it would not close when the battery was bad or not in the car, I don't think that is possible.
__________________
Ich liebe meinen Mercedes-Benz!
There is a sticky that I submitted a few years ago that explains how to re-synch after a battery disconnect/re-connect. It is embedded in the DYI sticky I think. If you have disconnected and re-connected the battery, you probably have other electrical issues that you have not discovered yet, so I recommend that you re-synch everything.