Chuck Lowe
asked on
Lock Access dialogbox to a certain directory
Is it possible to stop the user from changing the path that comes up in the dialogbox and not allow them to change it? Or at least only drill down into it.
we can set the default directory when the dialog box open, but we can not prevent the user from moving away from that directory.
ASKER
I know I can set it to a certain directory and I did. I'm guessing the only way to stop them is to do my own listbox and fill it (DIR command) with the files I find.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Not sure what your ultimate goal is here.
So please consider the Expert's posts above...
If your goal here is to set a certain top level folder that users can select a file from, ...then you can "List" all the files in a specific folder, and let the use select the file(s) from a listbox.
Basic code would look something like this:
In this way, they cannot ever navigate away because the path is set and you are not using the windows explore interface.
The downside here is that this cannot easily be made to allow user to drill down to other folders.
It will also not "look like" that standard file dialog box.
But calls for something like this are very popular nonetheless.
With these drawbacks in mind, I am just posting it here as an FYI, perhaps you can glean something useful from it.
;-)
JeffCoachman
So please consider the Expert's posts above...
If your goal here is to set a certain top level folder that users can select a file from, ...then you can "List" all the files in a specific folder, and let the use select the file(s) from a listbox.
Basic code would look something like this:
'Sets the Folder path/Name
Const strFolderName As String = "C:\YourFolder\"
Private Sub Command8_Click()
'Clear the form
'Call the sub that lists the files
Call ListFiles
'Clear the textbox
Me.Text6 = ""
End Sub
Private Sub Form_Open(Cancel As Integer)
'Call the sub that lists the files
Call ListFiles
End Sub
Sub ListFiles()
'List the files
Dim strFileName As String
Dim strFileList As String
strFileName = Dir(strFolderName & "*.jpg")
While Len(strFileName) > 0
strFileList = strFileList & strFileName & ";"
strFileName = Dir()
Wend
Me.lstFiles.RowSource = strFileList
End Sub
Private Sub lstFiles_AfterUpdate()
'Display the full FileNme
Me.Text6 = strFolderName & Me.lstFiles
End Sub
In this way, they cannot ever navigate away because the path is set and you are not using the windows explore interface.
The downside here is that this cannot easily be made to allow user to drill down to other folders.
It will also not "look like" that standard file dialog box.
But calls for something like this are very popular nonetheless.
With these drawbacks in mind, I am just posting it here as an FYI, perhaps you can glean something useful from it.
;-)
JeffCoachman
ASKER
That is exactly what I decided to do. I did try writing a custom dialog box but I had issues with letting them drill down. Although I will use the custom box when they are only to stay in one directory.
Thanks
Thanks