I believe you can make the sunroof work manually by doing as has been mentioned, removing the sunroof headliner by unsnapping it from the front edge of the sunroof (steel) panel, then lifting it out the openning in the roof. It is much harder to do this if the roof is closed.
Once the panel is out of the way the cable is attached to a cross beam at the rear of the sliding roof panel. Disconnect this and see if the roof can be moved by hand. Pulling the cross beam aft should release the roof panel and make it able to be slid open or closed all the way. If it won't move freely you will have to figure out the problem as something is not right - there will be some kind of rubbing or interference. Once you have that cleared up, you can check out the function of the motor and cable. With the cable disconnected there is no load to speak of, and you should be able to get the cable to move by turning the nut in the trunk. If yours is really broken off, get another from the dealer. It is just a plastic nut/cover and I believe the new one just pops back on over the stuff that is underneath the old one (which I believe is a clutch adjustment feature).
If the motor gears or the cable is bad you will have to replace one or both. I found the problems were with the attachement feature to the crossbeam on the end of the cable. But the only one I have worked on does not have the tilting feature, which complicates things significantly.
Electrical continuity is another story. Fuses, connections and the switch on the dash are all possible problems. You will have to sort these out one at a time. I found I had to wind the cable back into the motor area fully to reset the system, as for a while the unit only worked in one direction, then the open function closed the roof and the close function on the switch opened the roof. In the end it got fixed for a total of less than $0.50 for the new clip to the crossbeam. Good luck, Jim
1986 Euro 190E 2.3-16 (291,000 miles),
1998 E300D TurboDiesel, 231,000 miles -purchased with 45,000,
1988 300E 5-speed 252,000 miles,
1983 240D 4-speed, purchased w/136,000, now with 222,000 miles.
2009 ML320CDI Bluetec, 89,000 miles
1971 220D (250,000 miles plus, sold to father-in-law),
1975 240D (245,000 miles - died of body rot),
1991 350SD (176,560 miles, weakest Benz I have owned),
1999 C230 Sport (45,400 miles),
1982 240D (321,000 miles, put to sleep)