I am using the following code. Problem is that it when you select.. the filenames are not there. I am trying to select the filename, but only return its path to a cell. Can everyone help?
Please advise and thanks. -R-
Sub Test_GetFolder()
MsgBox GetFolder("Get My Folder", ThisWorkbook.Path)
Range("A3") = ThisWorkbook.Path
End Sub
Function GetFolder(Optional sTitle As String = "Select Folder", _
Optional sInitialFilename As String)
Dim myFolder As String
With Application.FileDialog(msoFileDialogFolderPicker)
If sInitialFilename = "" Then sInitialFilename = ThisWorkbook.Path
.InitialFileName = sInitialFilename
.Title = "Greetings"
If .Show = -1 Then
GetFolder = .SelectedItems(1)
If Right(GetFolder, 1) <> "\" Then
GetFolder = GetFolder & "\"
End If
Else: GetFolder = ""
End If
End With
End Function
Please advise and thanks. -R-
Sub Test_GetFolder()
MsgBox GetFolder("Get My Folder", ThisWorkbook.Path)
Range("A3") = ThisWorkbook.Path
End Sub
Function GetFolder(Optional sTitle As String = "Select Folder", _
Optional sInitialFilename As String)
Dim myFolder As String
With Application.FileDialog(msoFileDialogFolderPicker)
If sInitialFilename = "" Then sInitialFilename = ThisWorkbook.Path
.InitialFileName = sInitialFilename
.Title = "Greetings"
If .Show = -1 Then
GetFolder = .SelectedItems(1)
If Right(GetFolder, 1) <> "\" Then
GetFolder = GetFolder & "\"
End If
Else: GetFolder = ""
End If
End With
End Function