I have a G22 and G23 with 9mm and .357 SIG conversion barrels. One of the main reasons I switched to the .40 S&W Cal G22, and G23, and sold off all my 9mm Glocks, was for increased versatility with caliber conversion barrels. You can easily turn a .40 Glock into a 9mm Glock with only a barrel conversion, but as posted above, you can't turn a 9mm Glock into a .40 without a .40 slide.
While it may be possible to use a Glock 17 barrel in a G22 slide, the breech face and barrel hood and barrel diameter are all bigger with the G22. The smaller G17 barrel will be quite sloppy in the G22 slide.
best solution ...start your caliber conversion platform with the .40.