I had a problem that was similar, though not exactly the same. The key battery died, and I was unable to lock or unlock the doors with the key fob. I replaced the battery with a new, fresh one, and the key still wouldn't work. I put the key in the ignition, started the car, and drove it for a block. After that, the fob opened and locked the doors. I don't know if starting it refreshed the security code, or caused the car to recognize the key code again after the battery was replaced, or why it worked -- but it did work.