View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Steve Yandl Steve Yandl is offline
external usenet poster
 
Posts: 284
Default Is there a Folder Picker method that shows files too?

Below is a section of a routine where I wanted to let the user navigate to a
Word document from Excel (starting to look in the 'My Documents' folder).
If you want all types of files visible, do the .filter.clear but don't
follow up with .filter.add like I do in the example.

____________________________
Dim fd As FileDialog
Dim vrtSelectedItem As Variant
Dim myStoryDoc As String

Set objWd = CreateObject("Word.Application")

' Determine Path to the My Documents folder
Set objShell = CreateObject("Shell.Application")
Set objMyDocsFldr = objShell.Namespace(&H5&)
strMyDocsPath = objMyDocsFldr.Self.Path

' Create a file picker dialog opening to My Documents
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
..Filters.Clear
..Filters.Add "Word Documents", "*.doc"
..InitialFileName = strMyDocsPath
If .Show = -1 Then
For Each vrtSelectedItem In .SelectedItems
myStoryDoc = vrtSelectedItem
Next vrtSelectedItem
End If
End With

If Len(myStoryDoc) 8 Then
Set objDoc = objWd.Documents.Open(myStoryDoc)
___________________________

Steve Yandl



"tenlbham" wrote in message
...
I want to browse for a folder where certain files are located. The code is
just the basic:

With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = True
If .Show = False Then Exit Sub
MyFolder = .SelectedItems(1)
End With

... but is there a way to be able to see the files in the browser as well
as
the folders?

Thanks!