View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Flanagan Bob Flanagan is offline
external usenet poster
 
Posts: 340
Default selectfile control

The example below will display the Windows directory dialog and let a user
select any directory. It will return the path to that directory.

Place this type declaration and the next two functions at
'the top of the module
Public Type BROWSEINFO
hWndOwner As Long
pidlRoot As Long
sDisplayName As String
sTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type

Declare Function SHGetPathFromIDList Lib "shell32.dll" _
Alias "SHGetPathFromIDListA" _

(ByVal pidl As Long, ByVal pszPath As String) As Long

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

Sub DemoGetPath()
Dim anyPath As String
anyPath = DirectoryName("Select destination folder")
If anyPath = "" Then
MsgBox "No directory selected"
Else
MsgBox anyPath
End If

Robert Flanagan
Macro Systems
Delaware, U.S. 302-234-9857
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel


"al ramirez" wrote in message
...
i need a control that will return a "path"
can i use a "selectfile" or another control in a form,
and how do i use it (an exemple will be greatly
appreciated) thanks in advance