#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8
Default get a folder name

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
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default get a folder name

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

"linto" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8
Default get a folder name

thanks mike


"Mike H" wrote:

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

"linto" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pulling pdf files from general folder to specific folder [email protected] Excel Discussion (Misc queries) 2 September 8th 09 09:41 PM
how can i change my default working folder to a networked folder? wizard1154 Excel Discussion (Misc queries) 4 April 18th 07 07:29 PM
How to decide folder-depth or How to select more folders/subfolders (folder-tree) ? Subteam Excel Discussion (Misc queries) 2 May 7th 06 08:14 PM
Need code to save file to new folder, erase from old folder Ron M. Excel Discussion (Misc queries) 1 February 24th 06 06:02 PM
how can I specific a folder with wildcard criteria and excel will import all the correct files in that folder? Raven Excel Discussion (Misc queries) 1 January 24th 06 03:28 PM


All times are GMT +1. The time now is 09:38 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"