Solved

SendKeys in Excel Macros

Posted on 2001-08-10
6
1,945 Views
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?
0
Comment
Question by:EDC
  • 3
  • 2
6 Comments
 
LVL 17

Expert Comment

by:calacuccia
ID: 6374507
Hi EDC,

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

Here it is:

ActiveSheet.Cells(1,1).Select

or

ActiveSheet.Range("A1").Select
0
 
LVL 2

Accepted Solution

by:
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
0
 
LVL 2

Expert Comment

by:sergeTD
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
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:EDC
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..
0
 

Author Comment

by:EDC
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!
0
 
LVL 2

Expert Comment

by:sergeTD
ID: 6399937
Hi EDC,
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.
SergeTD,
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Introduction Perhaps more familiar to developers who primarily use VBScript than to developers who tend to work only with Microsoft Office and Visual Basic for Applications (VBA), the Dictionary is a powerful and versatile class, and is useful …
My experience with Windows 10 over a one year period and suggestions for smooth operation
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now