Bman, I had the same problem with my 89 525i. Lost battery power with the sunroof open and when the battery was recharged, sunroof would not close, just heard clicking when the button was pressed. First I removed the cover, thinking it was the switch, but replaced the switch and it did not fix the problem. I then called my local service advisor and he told me that when power is lost, the sunroof switch (or motor, I can't remember which) is self-resetting. Have you tried all switch settings to open and close the sunroof? For instance, my sunroof closed when I pushed what would normally be the open button. Not sure how this all worked, but my roof then closed, then operated as normal. Hope this helps.