|
|
Question : Set initial dir of SHBrowseForFolder function
|
|
I'm using the API function SHBrowseForFolder to browse for a folder, but each time the window is opened, is set to "My Computer", and I would like to set into an initial directory. Any help welcomed. TIA.
|
Answer : Set initial dir of SHBrowseForFolder function
|
|
I used VB6 to create a DLL, and in that DLL, was able to show a form.
I don't know if you can make DLLs with VB 5, but I'm pretty sure you can.
I made a class, 'Class1':
Option Explicit
Public Function ShowMyForm() As String
Form1.Show 1 ShowMyForm = s Unload Form1 End Function
Private Sub Class_Initialize() s = "" End Sub
then I made form1, with 1 textbox, and 1 button:
Option Explicit
Public MyVal As String
Private Sub Command1_Click() s = Me!Text1.Text Unload Me End Sub
Then I compiled it into a DLL.
In Access, I set a reference to the project. Then I used this code:
Sub wada()
Dim c As New Project1.Class1 Dim s As String s = c.ShowMyForm() Debug.Print s Set c = Nothing Stop End Sub
Debug.Print s prints to the debug window what I typed in the textbox before closing the form in VB.
I'm thinking that you could make the same thing, but with a form having a DriveListBox object, and a DirListBox object. You could set up the DLL using property Let procedures, setting them to the directory that you want to be the 'default', and then show the form with the controls on it, having them adapt themselves according to the properties that were set.
When you close the form, (it must be modal...), read the controls first, then send the values back to Access through the return value of the Function that showed the form.
What do you think?
|
|
|
|
|