get a folder name

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
 
M

Mike H

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
 
L

linto

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top