Can I Replace the motor on a 450w impact drill with a 400w motor from my other drill.?
Unless the motors have identical sizes, identical mounting means, identical output shafting and identical wiring connections then there is no chance of this even being feasible. You already mention that various aspects of the two drills including the cases and attachment options are slightly different sizes so it is highly likely that there are internal differences as well. Take note of how much the case of modern drills (and other tools as well) is integral to holding all internal components including the motor, gear train, brushes if applicable, wiring and switches and it becomes clear that the motors are likely to be different as well. 

It also seems foolish to cannibalize a working tool to repair a broken tool. It is far better to realize that tools have a lifetime, especially if they are used a lot in a trade or have been subjected to a lot of hours of use, and that they will require replacement from time to time. Higher end tools can sometimes be cost effectively be repaired by purchasing replacement parts but it is often the case that it is almost better to just replace broken tools with new ones.