View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
RB Smissaert RB Smissaert is offline
external usenet poster
 
Posts: 2,452
Default SendKeys {HOME} not working

I don't always want the first file, but I need the focus somewhere to start
selecting files with the keyboard. The first file seems a sensible choice.

RBS


"Lars Hammarberg" wrote in message
...
The only reason for using GetOpenFilename I know of is to let the user
select one or several files. If you know you always want the first file
(alphabetically sorted?) in a folder, why not use the Scripting.Filesystem
object in the Scripting Runtime?

/Lars Hammarberg
www.camako.se
MSProject Premier Partner

"RB Smissaert" wrote in message
...
Trying to get the first file selected when doing
Application.GetOpenFilename.
In Excel 2002 I could do:

SendKeys "{TAB 7}", False

FileNameToOpen = _
Application.GetOpenFilename(FileFilter:="Text Files (*.txt), *.txt",

_
Title:="")

and that worked fine.

In Excel 2003, it only works partially in that the first file has the

dotted
line around it, but doesn't actually have the focus. If I do the HOME

key
manually the first file gets the focus, but doing:

SendKeys "{TAB 7}", False
SendKeys "{HOME}", False

FileNameToOpen = _
Application.GetOpenFilename(FileFilter:="Text Files (*.txt), *.txt",

_
Title:="")

doesn't work. Adding SendKeys "{HOME}", False just doesn't make any
difference. Tried it with the UP, DOWN, LEFT and RIGHT keys, but that

didn't
work either.
Any suggestions how to do this?


RBS