get a folder name

  • Thread starter Thread starter linto
  • Start date Start date
L

linto

i am using the following code for getting user input for a folder name.
i got this code from a book.
it works well but
how do i get the complete path of the folder assigned to a string variable?
like "UserFile"

With Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName = Application.DefaultFilePath & "\"
.Title = "Please select a location for saving the Work Request"
.Show
If .SelectedItems.Count = 0 Then
MsgBox "Location to save WR not selected"
Else
MsgBox .SelectedItems(1)
End If
UserFile = SelectedItems.Value 'is this right?
End With
 
Hi,

You already had the answer in your code, try this

With Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName = Application.DefaultFilePath & "\"
.Title = "Please select a location for saving the Work Request"
.Show
If .SelectedItems.Count = 0 Then
MsgBox "Location to save WR not selected"
Else
MsgBox .SelectedItems(1)
UserFile = .SelectedItems(1) 'is this right? No but this is
End If
End With

Mike
 
thanks mike


Mike H said:
Hi,

You already had the answer in your code, try this

With Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName = Application.DefaultFilePath & "\"
.Title = "Please select a location for saving the Work Request"
.Show
If .SelectedItems.Count = 0 Then
MsgBox "Location to save WR not selected"
Else
MsgBox .SelectedItems(1)
UserFile = .SelectedItems(1) 'is this right? No but this is
End If
End With

Mike
 
Back
Top