Why doesn't "Sendkeys" work reliably for me?

  • Thread starter Thread starter Cloudfall
  • Start date Start date
C

Cloudfall

I have the following code:

Workbooks.Open "C:\ABNLookUp.xls"
:
Application.Run "ABNLookUp.xls!ABRPublicLookup"
Application.SendKeys "{ENTER}"

I open a Government developed and protected spreadsheet and then run
its main (or only??) macro. This works. A tabbed form opens in
"ABNLookUp" starting the macro. The tabbed form has a "Start/Exit"
choice with "Start" highlighted. Hitting the "Enter" key starts the
application. So I code:

Application.SendKeys "{ENTER}"

This does not work. Nothing starts. My macro finishes execution.

I have never had any luck with "Sendkeys". Does anybody know how to use
them reliably? I thank you now for any advice.

(By the way, Excel Help, just out of the blue only late this afternoon,
is not letting me enter my queries because the cursor has turned into
this- "<-->". If anyone has any thoughts as to why I should be punished
this way I'd be glad to hear them. Am I "cursed" or "cursored"? Why has
it turned to custard? What have I done and can I undo it?).
 
I think that this is the reason you see so few people using Sendkeys. It's just
not reliable enough for most developers.

And just a guess...

If you reverse the order, does that help?

Application.SendKeys "{ENTER}"
Application.Run "ABNLookUp.xls!ABRPublicLookup"

Sometimes, buttons have an accelerator key that you can use (manually) with the
alt-key. It's the one underlined in the caption.

Application.SendKeys "%S"

If the leading S were underlined. It might work???

(I don't have a guess about the help problem.)
 
Thank you for the feedback regarding the unreliability of Sendkeys. I
wasn't aware of this. I don't know or work with anyone else who
programs in VBA. I thought it was just my fault yet again.

I use Sendkeys in another program I wrote. It works if its the only
thing running. It doesn't if it isn't.

Reversing the order didn't work, but it did remind me that there are
times when this has in the past.

Unfortunately the other application doesn't use accelerator keys and
there are no letters underlined in the captions.

It's not the end of the world. If I could have gotten this working it
would have been an elegant solution. However, they're pretty impressed
and happy with what I've already done.

(I rebooted Excel on Friday and Help still didn't work. Today, Monday,
Help is working again just fine. A riddle wrapped in a mystery inside
an enigma.)

Thank you for your efforts (yet again!!!) on my behalf. All the best.
:-)
 
Back
Top