Thanks for reaching out to us on HP Support Forums. 🙂 I came across your post and would like to help.
I understand that you have an HP ENVY 5540 All-in-One Printer. I read that the printer print and copies fine but will not scan. While trying to scan there are error messages like the connection to the printer has been lost, An OCR application is not installed on this computer. I appreciate the steps you have performed and have certainly done a good job.
It indicates that it is purely an issue with the driver or scan settings because the copying works fine. I recommend you to perform the following steps to isolate the issue and arrive at a fix:
I suggest you to uninstall the drivers from the root level by following the below steps and then reinstall them:
In Windows, search for and open Programs and Features.
Select your HP printer.
In Windows, search for and open Devices and Printers.
In the Devices and Printers window look for your HP Printer. If you see it listed, right-click on it and choose "Delete" or "Remove Device.”
Open up the run command with the "Windows Key + R" key combo.
Type printui.exe /s and click OK.
Click on Drivers tab.
Look for HP Printer driver. If you see it click on it and click Remove at the bottom.
Select Apply and OK on the Print Server Properties windows.
Close Devices and Printers.
You may download and install the drivers from this link for your printer.
This should work. You may have to restart the computer and the printer once to make it work.
I sincerely hope this fixes the issue. Keep me posted. Cheers! 🙂