Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Directory browser


Hi,

Does anyone know a directory selector control? (browsing fo
directories without having to select a specific file)

Thanks,

Ana

--
Ana
-----------------------------------------------------------------------
Anat's Profile: http://www.excelforum.com/member.php...fo&userid=1670
View this thread: http://www.excelforum.com/showthread.php?threadid=31914

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Directory browser

Anat,

Here is one way. I believe that XL2002 has a browse dialog. I don't use 2002
myself, so you may need to play with this, but this is basically it

With Application.FileDialog(msoFileDialogFolderPicker)
.Show

MsgBox .SelectedItems(1)

End With

Look up FileDialog in the VBA help

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

RP
(remove nothere from the email address if mailing direct)


"Anat" wrote in message
...

Hi,

Does anyone know a directory selector control? (browsing for
directories without having to select a specific file)

Thanks,

Anat


--
Anat
------------------------------------------------------------------------
Anat's Profile:

http://www.excelforum.com/member.php...o&userid=16706
View this thread: http://www.excelforum.com/showthread...hreadid=319142



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Directory browser

Hi Anat

Windows has one built in that you can use (if you use Windows that is). Se
Jim Rech's file
BrowseForFolder.zip
at
http://www.bmsltd.ie/MVP/Default.htm

HTH. Best wishes Harald

"Anat" skrev i melding
...

Hi,

Does anyone know a directory selector control? (browsing for
directories without having to select a specific file)

Thanks,

Anat


--
Anat
------------------------------------------------------------------------
Anat's Profile:

http://www.excelforum.com/member.php...o&userid=16706
View this thread: http://www.excelforum.com/showthread...hreadid=319142



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Directory browser

Bob,

I run XL2003 and the code you supplied (FileDialog) runs fine.

Just so you know.

Cheers


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Bob Phillips" wrote in message
...
Anat,

Here is one way. I believe that XL2002 has a browse dialog. I don't use
2002
myself, so you may need to play with this, but this is basically it

With Application.FileDialog(msoFileDialogFolderPicker)
.Show

MsgBox .SelectedItems(1)

End With

Look up FileDialog in the VBA help

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

RP
(remove nothere from the email address if mailing direct)


"Anat" wrote in message
...

Hi,

Does anyone know a directory selector control? (browsing for
directories without having to select a specific file)

Thanks,

Anat


--
Anat
------------------------------------------------------------------------
Anat's Profile:

http://www.excelforum.com/member.php...o&userid=16706
View this thread:
http://www.excelforum.com/showthread...hreadid=319142





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Directory browser

Rob,

I assumed that if it ran on 2002 it would run on 2003 :-)

Bob


"Rob van Gelder" wrote in message
...
Bob,

I run XL2003 and the code you supplied (FileDialog) runs fine.

Just so you know.

Cheers


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Bob Phillips" wrote in message
...
Anat,

Here is one way. I believe that XL2002 has a browse dialog. I don't use
2002
myself, so you may need to play with this, but this is basically it

With Application.FileDialog(msoFileDialogFolderPicker)
.Show

MsgBox .SelectedItems(1)

End With

Look up FileDialog in the VBA help

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

RP
(remove nothere from the email address if mailing direct)


"Anat" wrote in message
...

Hi,

Does anyone know a directory selector control? (browsing for
directories without having to select a specific file)

Thanks,

Anat


--
Anat


------------------------------------------------------------------------
Anat's Profile:

http://www.excelforum.com/member.php...o&userid=16706
View this thread:
http://www.excelforum.com/showthread...hreadid=319142







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
what is a web browser msbenz Excel Discussion (Misc queries) 1 October 3rd 06 09:28 AM
Netscape Browser zweebo Excel Discussion (Misc queries) 0 March 18th 06 02:51 AM
BROWSER David Excel Programming 2 February 3rd 04 11:18 PM
Directory browser in Excel VB Mike Fogleman Excel Programming 3 December 19th 03 10:26 AM
Check if directory empty OR no of files in directory. Michael Beckinsale Excel Programming 2 December 4th 03 10:12 PM


All times are GMT +1. The time now is 10:49 AM.

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"