SendKeys in Excel Macros

Posted on 2001-08-10
Medium Priority
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 800 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
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.


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

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
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 …
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

764 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