The swingarm itself will fit, but there are differences in other parts. Both swing arms use the same swingarm pivot bolt and spacers between the frame and the engine, axles are the same and bearing carrier is the same. Other than that almost all parts are slightly different
If you can find a swingarm from a 2014 400X, it should fit your 400EX. You might need some parts off your EX in place of parts on the X (like the caliper mount), but don't just take my word for it - try to get advice from someone who has actually tried or done it. I am basing my conclusion on Honda part numbers.
Honda's part numbering system is this: the first 5 digits identify the part (52200 = swingarm for TRX series) - the next 3 digits identify the model used on (HN1 = 400EX & X) - the last 3 digits indicate a supplier, production change, material change, color change etc. The 2004 EX swingarm is 52200-HN1-020 while the 2014 X swing arm is 52200-HN1-A70
If you can find a swingarm from a 2014 400X, it should fit your 400EX. You might need some parts off your EX in place of parts on the X (like the caliper mount), but don't just take my word for it - try to get advice from someone who has actually tried or done it. I am basing my conclusion on Honda part numbers.
Honda's part numbering system is this: the first 5 digits identify the part (52200 = swingarm for TRX series) - the next 3 digits identify the model used on (HN1 = 400EX & X) - the last 3 digits indicate a supplier, production change, material change, color change etc. The 2004 EX swingarm is 52200-HN1-020 while the 2014 X swing arm is 52200-HN1-A70