Hi,
Do you mean the main battery in the car?
If so, here is a link which may be of some help, in reprogramming the key to the car. Try methods 1 and 3.
http://www.programyourkeys.com/BMW_Z3_Key_Remote_Control_Fob_Programming.html
If you mean the battery in the key itself, have you inserted the battery in the correct way.