browse
-
Hi.. I wish to share a small VB6 problem.. I want to display hte BrowseForFolder Dialog so the user can select a folder.. so I did this : add a reference to shell32.dll (or Microsoft Shell controls and Automation) the code : Option Explicit Dim sh As New Shell Dim f As Folder Private Sub Command1_Click() Set f = sh.BrowseForFolder(Me.hWnd, "SDFg", 0) MsgBox f.Title End Sub It works but it just gets the folder title not the path.. I wish to solve it using the Shell and Folder objects. ( I know the other solution using SHBrowseForFolder and SHGetPathFromIDList which you can find at : http://www.allapi.net/apilist/SHBrowseForFolder.shtml )
-
Hi.. I wish to share a small VB6 problem.. I want to display hte BrowseForFolder Dialog so the user can select a folder.. so I did this : add a reference to shell32.dll (or Microsoft Shell controls and Automation) the code : Option Explicit Dim sh As New Shell Dim f As Folder Private Sub Command1_Click() Set f = sh.BrowseForFolder(Me.hWnd, "SDFg", 0) MsgBox f.Title End Sub It works but it just gets the folder title not the path.. I wish to solve it using the Shell and Folder objects. ( I know the other solution using SHBrowseForFolder and SHGetPathFromIDList which you can find at : http://www.allapi.net/apilist/SHBrowseForFolder.shtml )
After you get the Folder object, use the FolderItems collection, like:
Dim fiPath As String Set f = sh.BrowseForFolder(Me.hWnd, "SDFg", 0) Set fi = f.Items.Item filePath = fi.Path MsgBox filePath
This will give you the full path of the item that was selected. You may need to add some checking against the FolderItem object because is maybe a 'special' folder and not have a Path associated with it (i.e MYCOMPUTER). Roger Stewart "I Owe, I Owe, it's off to work I go..."