Ok, so once the fob stopped working or definitely when you removed the battery then the fob lost its coding to the car.
This is why when you re-assembled it, it still did not communicate with the car.
Some car owners manuals state how to get the fob re-programmed to the car, for others it is only in the workshop manual.
You best bet would likely be a locksmith who deals with cars.
Note, some cars need to re-program fobs with the car in pairs - however this is not true of all cars.
First step talk to a locksmith, find a good one in your area - some local websites may help you choose.
You might find that checking with your insurance will give you a local locksmith... If that matches the local advice then even better.
Downvoted by those who have not had to deal with a PATS system where the fob is actually designed to change its code all the time...
These are the instructions for my Jaguar, and do note at the end where it mentions the codes change...
Programming or pairing a new remote Key fob for the X Type is a very simple job that will cost a substantial amount if it is done by Jaguar. It's annoying but this may need to be done if your Key fob battery has been allowed to go flat, or the car battery has been removed for any length of time.
Follow these steps exactly and you should have no problems, pairing old or replacement Key fobs for your car.
1.)I would recommended that you ensure all key fobs are fitted with new batteries. ( Click here to see battery replacement guide).
2.)Get in the car and close the drivers side door.
3.)Put the key into the ignition and turn to position I.
4.)Wait 5 seconds
5.)Turn the key quickly to position II then back to I four times. (do this only once)
6.)You should hear a single chime.
7.)Remove the Key
8.)For each Key fob in rapid succession. Press any single button on the key fob you wish to pair, you should hear a chime as each Key fob is paired with the security system. After the chime press a button on the next Key fob you wish to pair.
9.)On completion after all keys have been programed, wait 3 minutes then check the operation of each Key fob by locking/unlocking the vehicle.
Important Note :-All the fobs that you wish to use Must be paired at the same time. Every time you operate the key as in step 5 above the code will be changed, previously programmed fobs will no longer work unless you pair them all at the same time.