Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dispay word dialog box and set the focus 1

Status
Not open for further replies.

pallottino

Technical User
Apr 7, 2003
12
0
0
IT
Into a MSWord macro I need to display the

FileOpen dialog box with the focus on the list of file and noto on the filed "name" as default.

How can I set the focus (i.e. the position of the cursor) into a word dialog box?

With Dialogs(wdDialogFileOpen)

???

.Show

End With



Thanks in advance for the answer

 
This seems to work in Word 97:
Code:
Option Explicit
Sub test()
  SendKeys "+{TAB}"
  With Dialogs(wdDialogFileOpen)
    .Show
  End With
End Sub
Of course, if MS changes the layout of the dialog, shift-tab may no longer take you where you want to go.
 
Great! This is the solution I was seeking for months!

Short and sharp; in Italy it would be called a "Columubus's egg".

It works perfectly in Word 2000 SP-3 on Windows 2000 Professional (the system I'm using) too.

And I think that the solution will also work with all the MSWword-dialog boxes.

I beg tour pardon for my spell mistakes.

Thank you very much

Paolo
 

Zathras's solution has an odd behavior:

if I launch my macro by A) clicking a button on a toolbar or B) pressing a Functionkey (like F6 or F10 etc.) it works right

else if I launch the same macro by C) pressing a combination like ALT+functionkey or CTRL+functionkey, the Sendkey command can't move the focus from the field "Name" ! !

Carol's solution would be the best if the file list into the FileOpen word-dialog-box would have a field name...
but Ican't find the name of this field !!

I can't imagine there's no solution for a so normal problem baut I'm not able to find it

Please help me
 
If you really need the functionality, the you can create a separate .exe file to send the shift-tab to the "Open" dialog box. For example, I used WinBatch to create an .exe file that allows this form of the macro to work:
Code:
Sub test()
Dim wbHandle
Dim fileToOpen
  wbHandle = Shell("d:\winbatch\shifttab.exe", vbMinimizedNoFocus)
  fileToOpen = Application.GetOpenFilename("Excel Files (*.xls), *.xls")
End Sub
The WinBatch script looks like this;
Code:
Sounds(0)
SendKeysTo( "Open" , "+{TAB}" )
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top