In Europe, at least, the sword was beginning to fall out of favor as a weapon of war during the period of the musketeers - 1600 or so. Their name means, essentially, one who carries/uses a musket. They still used the sword extensively in close quarters, but warfare was starting to be held more at arm's length.
However, melee weapons did not fall into total disuse until sometime after colt and winchester invented revolvers and repeating rifles. The American Cavalry still carried and were trained in the use of swords through the 1800s, I believe, partially because they were fighting foes (i.e. American Indian tribes) who made heavy use of primitive weapons in addition to picking up and showing an apptitude for rifles.