This should help:
1. Make sure all doors, hood and trunk are closed.
2. Open the trunk door.
3. Open the drivers door and sit in the drivers seat.
4. Close the drivers door.
5. Turn ignition switch to on and off 5 times ending in off.(do not start the car turn to just before starting)
Your alarm light will turn on and the siren on the alarm will chirp to let you know it is ready.
(this can also be used to test if you have the alarm)
6. Open the drivers door stay in the seat close the drivers door.
7. Press any button on the remote. The light will flash to indicate your remote has been programmed.
8. Repeat steps 6 & 7 to program any other remotes, up to 4 remotes a car.
9. To exit program mode open drivers door leave the door open. Close the trunk lid and close the drivers door the
siren should chirp again and the red light will shut off. Test your remotes to make sure they work right.
******Note all the steps from 2 - 5 must be done within 45 seconds. Step 5 must be done within 10 seconds.
Link: 1997 BMW 328i - Free Keyless Remote Fob Entry programming instructions, procedures for all automotive vehicles
It sounds a bit like a rain dance however I know that it works, I have done it myself multiple times.