Is there a way to control a FileDialog in VBA so that the cursor moves to the top of the File List in an open FileDialog? (The cursor always seems to be in the File name control of the FileDialog.)
I would like to use the down arrow key to move through the list of files in the initial folder of an open FileDialog. (Rather than use the mouse to select a file in the File List.)
Hitting the TAB key 10 times moves the cursor to the top of the list, but I would like to automate that process. Best as I can tell, I cannot use SendKeys - either before .Show or after. So I do not think I can pass {TAB} as a keystroke programmatically.
I am writing the code in Outlook but need to use Excel because Outlook does not support the FileDialog.
This is taken from a larger function.
'Launch File Browser
'NOTE: Outlook actually does NOT support the FileDialog, so you need
' to hack a solution and use another Office app instead
'This uses Excel to open the FileDialog
Dim xlobj As Excel.Application
Set xlobj = New Excel.Application
With xlobj.FileDialog(msoFileDialogFilePicker)
.InitialFileName = strStartFolderPath
.Filters.Add "All files", "*.*"
.Title = "Please Select a File to Attach"
.AllowMultiSelect = True
' Try SendKeys Here? - Does NOt work
SendKeys "{TAB}"
.Show
' Try SendKeys Here? Does NOT Work because VBA waits for FileDialog
'SendKeys "{TAB}"
For i = 1 To .SelectedItems.Count
varSelectedItem = .SelectedItems(i)
objItem.Attachments.Add varSelectedItem
Next i
End With
xlobj.Quit
Set xlobj = Nothing
Set myItem = Nothing
Set objItem = Nothing
Set myolapp = Nothing