No. The full size barrels use a different locking lug to the compact/sub compact models. Your 34 barrel will fit a 17 slide but that's it. You can interchange the compact and sub compact barrels though eg put a 19 barrel in a 26 or vice versa.
In any case you can't just plonk a standard 9mm barrel in a .40 slide, you have to buy a conversion barrel.