Browse For a File or Path and enter in a cell
Here is a modified version of the sub I posted earlier. This time, when the
user selects files and clicks 'OK', each file name is appended to Column A
and the corresponding path to the selected file is placed in Column B.
______________________________________
Sub UserGetMyDocsFiles()
Dim fd As FileDialog
Dim vrtSelectedItem As Variant
Dim R As Integer
Dim strPathName As String
Dim strFileName As String
R = Range("A65536").End(xlUp).Row + 1
' 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
arrFullName = Split(vrtSelectedItem, "\")
strPathName = ""
strFileName = ""
strFileName = arrFullName(UBound(arrFullName))
For X = 0 To UBound(arrFullName) - 1
strPathName = strPathName & arrFullName(X) & "\"
Next X
Cells(R, 1).Value = strFileName
Cells(R, 2).Value = strPathName
R = R + 1
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?
|