ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Prompting for a Directory Name (https://www.excelbanter.com/excel-programming/371287-prompting-directory-name.html)

Chaplain Doug

Prompting for a Directory Name
 
Excel 2003. I currently use "Application.GetOpenFilename" to prompt users to
browse to and select a file. It returns the full file name with path. Is
there a similar method by which I can prompt the user to select (browse to) a
folder (NOT a file) and have that folder's name and full path returned?
Thanks for any help.
--
Dr. Doug Pruiett
Good News Jail & Prison Ministry
www.goodnewsjail.org

Dave Peterson

Prompting for a Directory Name
 
Jim Rech has a BrowseForFolder routine at:
http://www.oaltd.co.uk/MVP/Default.htm
(look for BrowseForFolder)

John Walkenbach has one at:
http://j-walk.com/ss/excel/tips/tip29.htm

If you and all your users are running xl2002+, take a look at VBA's help for:
application.filedialog(msoFileDialogFolderPicker)

Chaplain Doug wrote:

Excel 2003. I currently use "Application.GetOpenFilename" to prompt users to
browse to and select a file. It returns the full file name with path. Is
there a similar method by which I can prompt the user to select (browse to) a
folder (NOT a file) and have that folder's name and full path returned?
Thanks for any help.
--
Dr. Doug Pruiett
Good News Jail & Prison Ministry
www.goodnewsjail.org


--

Dave Peterson

stevebriz

Prompting for a Directory Name
 

Private Sub CommandButton1_Click()

Dim lngCount As Long

' Open the file dialog
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = True
.Show

' Display paths of each file selected
For lngCount = 1 To .SelectedItems.Count
MsgBox .SelectedItems(lngCount)
Next lngCount

End With

End Sub


Tom Ogilvy

Prompting for a Directory Name
 
According to the help on AllowMultiselect, it is ignored for picking folders.

Has your experience been different?

--
Regards,
Tom Ogilvy


"stevebriz" wrote:


Private Sub CommandButton1_Click()

Dim lngCount As Long

' Open the file dialog
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = True
.Show

' Display paths of each file selected
For lngCount = 1 To .SelectedItems.Count
MsgBox .SelectedItems(lngCount)
Next lngCount

End With

End Sub




All times are GMT +1. The time now is 02:43 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com