To expand a little more on my previous post, if you can afford it, get the 7040. To my knowledge there is practically no difference in physical size or weight between the 5040, 6040, and 7040, so why not get the highest hp engine you can get?
The 5040 will easily handle the Hesston 530, 730, 540, 740, and maybe the 745 depending on the size of your hills. The Case-IH model number of the same balers are the 8420 and 8430(3.5'x4.5' and 4'x4'). Also the 5040 could handle the NH 630, 634, and 638 which are all 4'x4' machines.
The 6040 would easily handle the Hesston 745 or the Vermeer 5400 rebel or 5410 rebel, which all make up to a 4'x5' bale.
The 7040 (what I have) will handle the NH 640,644, and 648's.
Also if you went back to a little older machine something like a Hesston 5500 or 5510 or a Case-IH 8440 which all all 5'x5' machines the 7040 would handle easily. I had a Hesston 5500 before I bought my little 8420 and pulled it with my Kubota
M4700 so long as it wasn't too hot out and the crop wasn't too heavy. Course the older balers are getting a little tired, but there are many of the older spring tension models that pull easier than the newer hydraulic tension models.
Long story short, there are a lot of baler options out there for any of those tractors, but if you can afford it get the 7040 as the size and weight difference isn't much but the extra pto hp would leave you more baler options.