View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Steve Yandl Steve Yandl is offline
external usenet poster
 
Posts: 284
Default Browse For a File or Path and enter in a cell

Here is an option that will give you a browse window for files with the
initial focus on the 'My Documents' folder. You probably want to do
something more interesting than have a message box pop up with the path and
file name for each selected item though.

__________________________________

Sub UserGetMyDocsFiles()

Dim fd As FileDialog
Dim vrtSelectedItem As Variant

' 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
..InitialFileName = strMyDocsPath
If .Show = -1 Then
For Each vrtSelectedItem In .SelectedItems
MsgBox vrtSelectedItem
Next vrtSelectedItem
End If
End With

Set objShell = Nothing
Set fd = Nothing

End Sub

___________________________________

Steve Yandl



"D. Jones" wrote in message
...
Is it posssible in Excel 2003 to Browse to either select a file name or
path
that would be entered in a cell for reference or used in a macro?