PC Review


Reply
Thread Tools Rate Thread

Dialog box for user to select a folder

 
 
=?Utf-8?B?aG1t?=
Guest
Posts: n/a
 
      21st Nov 2006
I would like to include the GetOpenFilename method in a dialog box, in order
for the user to select a folder.

1. Can the method indeed be used to select a folder name?
2. Can I specify filtered browsing, that will display only folders?

Thanks.
 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      21st Nov 2006
XL2002 has a browse folder dialog.


With Application.FileDialog(msoFileDialogFolderPicker)
.Show


MsgBox .SelectedItems(1)


End With


Look up FileDialog in the VBA help


--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"hmm" <(E-Mail Removed)> wrote in message
news:4E81E96F-15A7-4746-BCD8-(E-Mail Removed)...
> I would like to include the GetOpenFilename method in a dialog box, in

order
> for the user to select a folder.
>
> 1. Can the method indeed be used to select a folder name?
> 2. Can I specify filtered browsing, that will display only folders?
>
> Thanks.



 
Reply With Quote
 
Jim Rech
Guest
Posts: n/a
 
      21st Nov 2006
And if you want to use the Windows 'Browse for Folder':

http://www.oaltd.co.uk/DLCount/DLCou...eForFolder.zip

Quite a bit more complicated however.

--
Jim
"hmm" <(E-Mail Removed)> wrote in message
news:4E81E96F-15A7-4746-BCD8-(E-Mail Removed)...
|I would like to include the GetOpenFilename method in a dialog box, in
order
| for the user to select a folder.
|
| 1. Can the method indeed be used to select a folder name?
| 2. Can I specify filtered browsing, that will display only folders?
|
| Thanks.


 
Reply With Quote
 
=?Utf-8?B?aG1t?=
Guest
Posts: n/a
 
      21st Nov 2006
Bob,

Thanks for the help.

I have Excel 2000. Is there any way it can be done in Excel 2000?

"Bob Phillips" wrote:

> XL2002 has a browse folder dialog.
>
>
> With Application.FileDialog(msoFileDialogFolderPicker)
> .Show
>
>
> MsgBox .SelectedItems(1)
>
>
> End With
>
>
> Look up FileDialog in the VBA help
>
>
> --
>
> HTH
>
> Bob Phillips
>
> (replace xxxx in the email address with gmail if mailing direct)
>
> "hmm" <(E-Mail Removed)> wrote in message
> news:4E81E96F-15A7-4746-BCD8-(E-Mail Removed)...
> > I would like to include the GetOpenFilename method in a dialog box, in

> order
> > for the user to select a folder.
> >
> > 1. Can the method indeed be used to select a folder name?
> > 2. Can I specify filtered browsing, that will display only folders?
> >
> > Thanks.

>
>
>

 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      21st Nov 2006
The pre XL2002 way is


Private Declare Function SHGetPathFromIDList Lib "shell32.dll" _
Alias "SHGetPathFromIDListA" _
(ByVal pidl As Long, _
ByVal pszPath As String) As Long


Private Declare Function SHBrowseForFolder Lib "shell32.dll" _
Alias "SHBrowseForFolderA" _
(lpBrowseInfo As BROWSEINFO) As Long


Private Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type


'-------------------------------------------------------------
Function GetFolder(Optional ByVal Name As String = _
"Select a folder.") As String
'-------------------------------------------------------------
Dim bInfo As BROWSEINFO
Dim path As String
Dim oDialog As Long


bInfo.pidlRoot = 0& 'Root folder = Desktop


bInfo.lpszTitle = Name


bInfo.ulFlags = &H1 'Type of directory to Return
oDialog = SHBrowseForFolder(bInfo) 'display the dialog


'Parse the result
path = Space$(512)


GetFolder = ""
If SHGetPathFromIDList(ByVal oDialog, ByVal path) Then
GetFolder = Left(path, InStr(path, Chr$(0)) - 1)
End If


End Function


--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"hmm" <(E-Mail Removed)> wrote in message
news:04184973-DBBE-4916-A3A0-(E-Mail Removed)...
> Bob,
>
> Thanks for the help.
>
> I have Excel 2000. Is there any way it can be done in Excel 2000?
>
> "Bob Phillips" wrote:
>
> > XL2002 has a browse folder dialog.
> >
> >
> > With Application.FileDialog(msoFileDialogFolderPicker)
> > .Show
> >
> >
> > MsgBox .SelectedItems(1)
> >
> >
> > End With
> >
> >
> > Look up FileDialog in the VBA help
> >
> >
> > --
> >
> > HTH
> >
> > Bob Phillips
> >
> > (replace xxxx in the email address with gmail if mailing direct)
> >
> > "hmm" <(E-Mail Removed)> wrote in message
> > news:4E81E96F-15A7-4746-BCD8-(E-Mail Removed)...
> > > I would like to include the GetOpenFilename method in a dialog box, in

> > order
> > > for the user to select a folder.
> > >
> > > 1. Can the method indeed be used to select a folder name?
> > > 2. Can I specify filtered browsing, that will display only folders?
> > >
> > > Thanks.

> >
> >
> >



 
Reply With Quote
 
=?Utf-8?B?aG1t?=
Guest
Posts: n/a
 
      22nd Nov 2006
Thanks to all for your answers, but whew! I may just use GetOpenFilename,
asking the user to select any file in the folder, then parsing the path
string for the folder. Glad that later versions of Excel simplify the task.

"hmm" wrote:

> I would like to include the GetOpenFilename method in a dialog box, in order
> for the user to select a folder.
>
> 1. Can the method indeed be used to select a folder name?
> 2. Can I specify filtered browsing, that will display only folders?
>
> Thanks.

 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      22nd Nov 2006
But if you tuck it away in a separate module, you can then forget about it.
That is effectively what all builtin functions do for you.

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"hmm" <(E-Mail Removed)> wrote in message
news:30F81C0A-36B7-4ECB-8FB3-(E-Mail Removed)...
> Thanks to all for your answers, but whew! I may just use GetOpenFilename,
> asking the user to select any file in the folder, then parsing the path
> string for the folder. Glad that later versions of Excel simplify the

task.
>
> "hmm" wrote:
>
> > I would like to include the GetOpenFilename method in a dialog box, in

order
> > for the user to select a folder.
> >
> > 1. Can the method indeed be used to select a folder name?
> > 2. Can I specify filtered browsing, that will display only folders?
> >
> > Thanks.



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Select User/Group A/c Dialog ? Ravi Shankar Microsoft VB .NET 0 14th Aug 2008 04:46 PM
Select folder dialog box =?Utf-8?B?Um9iZXJ0IEZvbmRh?= Microsoft Access 6 13th Jul 2006 04:02 AM
File Dialog API - Select Folder =?Utf-8?B?RkJ4aWlp?= Microsoft Access VBA Modules 4 13th Feb 2006 10:24 AM
Mapi folder select dialog =?Utf-8?B?TW9yaXR6?= Microsoft Outlook Form Programming 1 8th May 2005 07:10 PM
File open dialog... select folder only MC D Microsoft VB .NET 4 5th Mar 2004 07:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:59 AM.