Sadly I think you'll be replacing the logic board.
Hope it's under apple care.
I have a macbook mid 2007 that shuts down immediately after it is unplugged from AC. I've tried the battery on another machine and it works fine as well as trying a known good battery in this machine.Also I've tried a known good AC adapter. Other things I have done are run the hardware test which shows no errors, reset the smc and Pram, repaired permissions etc. the battery appears normal in the menu bar and says it is fully charged.Also it Appears in system information as normal.coconut battery also appears normal with 275 cycles.I'm hoping the problem lies in the Battery Connector with Sleep Switch and not the logic board. Anyone had any experience with this problem?
One other strange thing is that after unplugging the AC the system shuts down immediately, but once you plug it back in it starts without the power button being pressed.