Yes, America had an active Communist Party in the 1940 election – there was a Presidential candidate as well as numerous State and local candidates running for public office that year. The Communist Party wasn’t outlawed then – the Communist Party was alive and actively running members for office and had been for several years.
The 1940 candidate for President was Earl Browder, who was also the National Chairman of the part from 1935 until 1945. He ran for President in 1936 and in 1940. In October of 1940, just weeks before the election, Browder was indicted by a Federal grand jury for passport fraud and was sentenced to 4 years in prison in early 1941. He served some 14 months of that sentence and was released in early 1943 as a goodwill gesture by FDR.
Browder was a staunch supporter of closer ties between the U.S. and the Soviet Union, and he envisioned a closer association between the two powers after World War 2. However, the death of FDR brought a halt to further association and the Red Scare and subversive activities of the of the Cold War atmosphere considerably changed the focus of the American Communist Party as a result. Browder would later run afoul of the party during the Red Scare years. wanting to maintain the status quo with the party and not make modifications in purpose and ideology resulting the Stalin Cold War era. Browder was expelled by the party in 1946. After then, he never regained his former status and lived out the rest of his life in comparative obscurity until his death in 1973.
For those who know about Earl Browder, but have never heard his voice, here is that campaign address, which was broadcast nationwide under the Equal Time rule for political candidates on October 10, 1940.