DianaStarr
asked on
vba How to highlight a default file when FilePicker Dialog opens
Can anyone tell me how to highlight a default file when I show the FilePicker dialog, but still leave the other files available for selection?
There are multiple files in a folder with the same naming convention. I want to highlight the most recent file as a default, but still allow the user to select an earlier file.
Here's a code snippet
Set dlgOpen = Application.FileDialog(mso FileDialog FilePicker )
dlgOpen.Filters.Clear
dlgOpen.Filters.Add "Excel Files (*.xls)", "*.xls", 1
FileName = "C:\temp\" & "MyFile [mmddyyyy].xls"
' -- where I would substitute the most recent date in the [mmddyyyy]
dlgOpen.InitialFileName = FileName
dlgOpen.AllowMultiSelect = False
If dlgOpen.Show = -1 Then
'set the variable that will be returned.
FilePath = dlgOpen.SelectedItems(1)
Else
'MsgBox "No file was selected."
ChangeFileLocation = False
End If
There are multiple files in a folder with the same naming convention. I want to highlight the most recent file as a default, but still allow the user to select an earlier file.
Here's a code snippet
Set dlgOpen = Application.FileDialog(mso
dlgOpen.Filters.Clear
dlgOpen.Filters.Add "Excel Files (*.xls)", "*.xls", 1
FileName = "C:\temp\" & "MyFile [mmddyyyy].xls"
' -- where I would substitute the most recent date in the [mmddyyyy]
dlgOpen.InitialFileName = FileName
dlgOpen.AllowMultiSelect = False
If dlgOpen.Show = -1 Then
'set the variable that will be returned.
FilePath = dlgOpen.SelectedItems(1)
Else
'MsgBox "No file was selected."
ChangeFileLocation = False
End If
ASKER
Thank you for getting back so quickly, but I don't think that FileSearch will give me the functionality I'm looking for. Tthe user must have the freedom to pick any file from the folder when the fileopen dialog pops up. What I'm looking for is a way to highlight or select the most recent file and STILL leave the others available.
I'm guessing that I will need to use some API calls to initialize the FileOpen dialog.
Thanks again,
d
I'm guessing that I will need to use some API calls to initialize the FileOpen dialog.
Thanks again,
d
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That's exactly what I needed...All I had to do was substitute my filters and provide the name of the default file.
Thank you.
Thank you.
http://www.ozgrid.com/forum/showthread.php?t=21485