using BrowseForFolder shell application

T

tiah

Hello !

I try to use this code :

Sub ChoixRepertoire()
Dim objShell As Object, objFolder As Object, oFolderItem As Object
Dim Chemin As String

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder(&H0&, "Choisir un
répertoire", &H1&)

On Error Resume Next
Set oFolderItem = objFolder.Items.Item
Chemin = oFolderItem.Path

MsgBox Chemin
End Sub

I have Excel 2002, and Windows XP.

I'd like to block the user from dragging folders in that window. Is it
possible ?

I don't want the user to move folders while seleting it.

I've tried with the API, but I cannot set the root folder, so the user
doesn't go anywhere else in the tree

thanks !

tiah.
 
J

Jim Rech

I don't see a way to block it. You might have to use:

Sub Test()
On Error Resume Next
With Application.FileDialog(msoFileDialogFolderPicker)
.Show
MsgBox .SelectedItems(1)
End With
End Sub


--
Jim
Hello !

I try to use this code :

Sub ChoixRepertoire()
Dim objShell As Object, objFolder As Object, oFolderItem As Object
Dim Chemin As String

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder(&H0&, "Choisir un
répertoire", &H1&)

On Error Resume Next
Set oFolderItem = objFolder.Items.Item
Chemin = oFolderItem.Path

MsgBox Chemin
End Sub

I have Excel 2002, and Windows XP.

I'd like to block the user from dragging folders in that window. Is it
possible ?

I don't want the user to move folders while seleting it.

I've tried with the API, but I cannot set the root folder, so the user
doesn't go anywhere else in the tree

thanks !

tiah.
 
T

tiah

thanks Jim, I cannot use that, since user will see the whole path.

do you know how to set the "top folder" ? to the api ?
 
J

Jim Rech

I haven't looked at it in years but I never had any luck setting the top
folder using the API method, other than to a system folder. All I could do
was set the initial folder using a callback.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top