I have had it unplugged for about 6 years.
Could be the source of the problem. Some other options:
1 — Click here 👉🏻 Use safe mode on your Mac - Apple Support, read, and do. That may be enough to get your going.
2 — Do you have the original system install/restore disks that came with the computer? If so, insert Disk 1 and restart the iMac holding the c key (NOT control or command). If the black screen is due to your surely-dead internal backup battery, the computer will often boot successfully from an optical system disk. Copies of the optical disk won't work.
3 — Click here 👉🏻 Target Disk Mode and read.
Connect the computer to another Mac using the cable methods listed in that support article. Start the 2007 in TDM by holding the "t" key during boot.
Normally you watch the screen of the older computer for an indication that your are in TDM. In your case, you will have to look at the screen of the newer computer and watch for the 2007's drive to appear as an external disk.
Once that happens you can drag/drop stuff from the old computer to the new.
Those methods assume that the dead backup battery is the sole culprit. If it's anything more serious, den.thed's wisdom prevails.