Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
User select Save To Folder | Excel Programming | |||
allow user to select folder | Excel Discussion (Misc queries) | |||
Prompt user to select file with default file selected dialog | Excel Programming | |||
Prompt user to select file with default file selected dialog | Excel Programming | |||
Prompt user to select file with default file selected dialog | Excel Programming |