Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
hmm hmm is offline
external usenet poster
 
Posts: 175
Default Dialog box for user to select a folder

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default Dialog box for user to select a folder

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" wrote in message
...
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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
hmm hmm is offline
external usenet poster
 
Posts: 175
Default Dialog box for user to select a folder

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" wrote in message
...
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.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default Dialog box for user to select a folder

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" wrote in message
...
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" wrote in message
...
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.






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Dialog box for user to select a folder

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" wrote in message
...
|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.




  #6   Report Post  
Posted to microsoft.public.excel.programming
hmm hmm is offline
external usenet poster
 
Posts: 175
Default Dialog box for user to select a folder

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.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default Dialog box for user to select a folder

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" wrote in message
...
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
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
User select Save To Folder Brad Excel Programming 4 November 16th 06 09:06 PM
allow user to select folder jbhoop Excel Discussion (Misc queries) 3 January 3rd 06 10:10 PM
Prompt user to select file with default file selected dialog Bruce Cooley Excel Programming 0 September 15th 03 06:43 AM
Prompt user to select file with default file selected dialog Bob Phillips[_5_] Excel Programming 0 September 14th 03 09:22 PM
Prompt user to select file with default file selected dialog Bob Phillips[_5_] Excel Programming 0 September 14th 03 09:19 PM


All times are GMT +1. The time now is 06:59 PM.

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

About Us

"It's about Microsoft Excel"