SendKeys in Excel Macros

Posted on 2001-08-10
Last Modified: 2012-06-21
When I include the command
     SendKeys "^{HOME}"
in an Excel 97 macro, I got a "VBA5.dll Not Found" error.  I installed Visual Basic Service Pack 3, which contains the file -- same results.  Then I copied the file to c:\WINNT\system32 and now get a Dr. Watson every time I run the macro.  I'm using NT 4.0, SP6.  What's going on?  Is there an alternative command to do a Ctrl-Home?
Question by:EDC
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 17

Expert Comment

ID: 6374507

The alternative I see is more simple than the sendkeys, but I do not understand why you have never tried this.

Here it is:




Accepted Solution

sergeTD earned 200 total points
ID: 6376218
To make effective the use of
"SendKeys "{home}", True" and others "Sendkey" instructions, you have to use LOTUS navigation keys:
->Menu TOOLS->Options->Tab TRANSITION->select "Transition   Navigation KEYS".
Hope this helps.
Serge TD

Expert Comment

ID: 6376237
I have also to precise an important point:

To be effective, the sendkeys instructions must not be executed in VBA Debug mode(step by step), so use F5 rather than F8 if you launch your macro from the Vbasic Window.

Serge TD
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 6379997
Thanks for your efforts!  However:

SergeTD, I launch my macro from a button on the spreadsheet.  And I turned on "Transition Navigation Keys" and still get the Dr. Watson.  (I even quit Excel and rebooted.)  And other users are getting the VBA5.dll error, too, even with "Transition Navigation Keys" on (I haven't bothered them further with taking them towards the Dr. Watson error).

Calacuccia, earlier in my macro I do some filtering and a freeze panes, so Ctrl-Home takes me to, for example, D880 -- but it may not be the same cell each time I run it..

Author Comment

ID: 6398841
Further investigation revealed that there is a problem with the particular workbook I am working with (it's the one that generates Dr. Watsons with MsgBox, OnTime, and who knows what else).  

When I used sergeTD's answer in another test workbook, it worked fine.  Thanks!

Expert Comment

ID: 6399937
I am pleased you have found a solution with my little help.
I am using very often Sendkeys and if you need more help
about them, just use a comment to this question: I will
try to help you furthermore.

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had the experience that you had to follow 10 steps over and over again every time when you need to nicely forward an important email to your manager? Fear no more! With the help of the Quick Steps feature in Outlook 2010, your old chor…
Outlook Free & Paid Tools
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question