Excel 2003, Vista, and Sendkeys

B

Bob Flanagan

Greetings. I just reformatted one of my PCs, installed Windows Vista and
then Excel 2003 so that I had a clean installation. I found that Sendkeys
does not work on Excel 2003 on Windows Vista. I recognize that Sendkeys
should only be used when all else fails, but there are those situations.

The solution is to do the following: (in this case for File, Open)

Dim wshShell
Set wshShell = CreateObject("WScript.Shell")
wshShell.SendKeys "%FO", True

Bob Flanagan
Macro Systems
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel
 
G

Gary''s Student

Hi Bob:

This is a little disturbing. If you run:

Sub test()
Range("A1").Select
Application.SendKeys "{F2}"
Application.SendKeys "Hi Bob"
Application.SendKeys "{ENTER}"
End Sub


would you get an error mesage ?
 
B

Bob Flanagan

I just ran the test on sending "hi bob" (that seemed the best to me <g>).
It does not work in Excel 2003 on a clean vista install. It does work on
Excel 2007.

Bob
 
B

Bob Flanagan

Nick, my example was just to illustrated a use of a simple sendkeys in 2003
on a Vista platform. Sendkeys (and Application.Sendkeys) is just ignored
when run by 2003 on Vista - and no error messages occured at all. Which is
very strange. It makes one wonder what else will not work in 2003 on a
Vista platform, and not give errors......

Bob Flanagan
Macro Systems
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel
 
B

Bob Flanagan

Nick, thanks for the link. It will be helpful. What is strange is that
sendkeys works in Excel 2007 on the same machine, but does not work in Excel
2003 on it. And there are simple work arounds. So, I doubt that it was
stopped from working due to security reasons. I suspect that Microsoft
screwed up is a more likely explanation. Not that they could do so.

There are some good reasons to use sendkeys. For example, say that your
last command in a macro is to delete cell entries. If done with vb code,
then undo will not work. If done with sendkeys, undo does work.

Bob
 
J

Jim Rech

Hi Bob-

I finally got to run the Hi Bob macro at home where I have Vista installed.
It ran fine in Excel 2003 with UAC off. With it turned back on the
Application.Sendkeys parts were not executed. Interestingly, if I used VB
Sendkeys (removing "Application.") they were executed.

I found both versions run in Excel 2007 with UAC on, as you did.

I don't use Sendkeys much but when I do I use the VB version. Just lazy I
guess.
 
B

Bob Flanagan

Hi Jim. I too don't use too often. I use where I can if it keeps undo
active.

Strangely, I had both Sendkeys and Application.Sendkeys not work in 2003.
It could be slight differences in installs and updates. I had not run any
updates on the PC as I want it as close to what I call the worst case
install of windows and Excel that I can think of.

Bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top