I set up a macro to do a quick scan of docs. It basically skips through all the dialogues and ends with the image centered to the page and with the crop tool selected whereby I crop and export as needed. Worked great until I installed a new Epson all-in-one printer. Which I figured would be a little different dialogue anyway. So I thought I could just alter the code a bit.
When the scan dialogue pops up it defaults with the "scan" button highlighted but I can't just hit enter for it to actually scan. I have to click on "scan". I can however hit alt+s and scanning starts. So I change my macro to wait a few seconds for the scan dialogue to come up then SendKeys "%(s)" but it won't do it.
Any ideas?
Is this in windows 7 ?
According to some forum posts, microsoft broke VBA sendkeys in windows 7 and still has not provided an official fix.
A fix is suggested at http://yottatricks.blogspot.co.uk/2012/03/enable-send-keys-functions-in-windows-7.html
I have not tested it, but it involves a reduction of security level. This is not just for sendkeys but for everything, so might not be a good thing to do.
Equally, it is unlikely that Corel could do anything to fix this. The proper fix needs to be provided by microsoft and should not need to a involve reduction of security for other functions.
Odd that I use SendKeys in other macros. I thought it might have something to do on the Epson side.
i.e.
Sub QuickScan()
SendKeys "{F2}" 'my shortcut for scan. scan starts but will not do next
SendKeys "%(s)" or SendKeys "{ENTER}"
Myron said: Odd that I use SendKeys in other macros. I thought it might have something to do on the Epson side. i.e. Sub QuickScan() SendKeys "{F2}" 'my shortcut for scan. scan starts but will not do next SendKeys "%(s)" or SendKeys "{ENTER}"
Most likely it is doing it, but doing it so fast it misses it.
Try this:
SendKeys ("{F2}") 'my shortcut for scan. scan starts but will not do next
Sleep 500 'puts in a half second pause
SendKeys ("{ENTER}")
Note that I've added parentheses around your commands.
If that doesn't work, change the 500 to 1000 or 1500.
If THAT doesn't work then I don't know.
Okay, Sleep 500 gives an error. I'm actually using another wait
Sub QuickScan() SendKeys "{F2}" Call WaitFor(6) SendKeys "%(s)" End Sub
--------------------------------------------------
Sub WaitFor(NumOfSeconds As Long)Dim SngSec As LongSngSec = Timer + NumOfSeconds
Do While Timer < SngSecDoEventsLoop
End Sub
-------------------------------
Nothing has worked. Turns out It's really not going to do me any good anyway. My new printer has an ADF so I can scan a double-sided doc but I have to tell it to use the ADF or not depending on my needs at the time.
Thanks all for the inputs though.
Ideally I could have 1 macro for single-sided and 1 for double-sided.
Myron said:Okay, Sleep 500 gives an error. I'm actually using another wait
Weird. I took that straight out of a macro I wrote that I use every day. Maybe the focus is still on the wrong window.
If you want to try again, try this:
Sub QuickScan() SendKeys "{F2}" Windows.FindWindow (Title) ' change Title to the name that shows on the scan window when it does pop up. Call WaitFor(6) 'or use the Sleep 500 here SendKeys "%(s)" End Sub
Anywho. Good luck!