|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Get Folder
I am working on some forms in access and looking for a way to get a user to broswe for a folder destination that i can then use as a destination for some exports.
|
|
#2
|
|||
|
|||
|
You can use the Microsoft Common Dialog Control (comdlg32.ocx) which should be located in your windows\system32 directory.
This control will allow you to use the windows common dialogs - which includes things like the color picker, printer dialog, and the file-open and file-save dialog windows. If you place an instance of the CommonDialog Control on your form along with a command button then try the code below: Private Sub Command1_Click() CommonDialog1.ShowSave MsgBox CommonDialog1.FileName End Sub The FileName property of the control should return the file the user selects/type in and the path. Hope this helps + good luck with your project. |
|
#3
|
|||
|
|||
|
thanks for the tip
I ended up using the methods described here URL seems to work pretty well, except no "New Folder" button |
|
#4
|
|||
|
|||
|
Here is a small tip that describes how to open the Browse for folder dialog via API from VB. With the Browse for folder dialog a user can select an existing directory from a directory tree. This example is build around a Function that will display the Browse for folder dialog and returns a directory if one is selected. This tip is inspired by code from VBnet.
Add this code to a Module: Option Explicit Declare Function SHBrowseForFolder Lib "shell32.dll" Alias _ "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias _ "SHGetPathFromIDListA" (ByVal pidl As Long, _ ByVal pszPath As String)As Long Const BIF_RETURNONLYFSDIRS = &H1 Type BROWSEINFO hOwner As Long pidlRoot As Long pszDisplayName As String lpszTitle As String ulFlags As Long lpfn As Long lParam As Long iImage As Long End Type Type ****EMID cb As Long abID As Byte End Type Type ITEMIDLIST mkid As ****EMID End Type '-- End --' Add this code to the Form: Function GetBrowseDirectory(Owner As Form) As String Dim bi As BROWSEINFO Dim IDL As ITEMIDLIST Dim r As Long Dim pidl As Long Dim tmpPath As String Dim pos As Integer bi.hOwner = Owner.hwnd bi.pidlRoot = 0& bi.lpszTitle = "Choose a directory from the list." bi.ulFlags = BIF_RETURNONLYFSDIRS pidl = SHBrowseForFolder(bi) tmpPath = Space$(512) r = SHGetPathFromIDList(ByVal pidl, ByVal tmpPath) If r Then pos = InStr(tmpPath, Chr$(0)) tmpPath = Left(tmpPath, pos - 1) If Right(tmpPath, 1) <> "\" Then tmpPath = tmpPath & "\" GetBrowseDirectory = tmpPath Else GetBrowseDirectory = "" End If End Function '-- End --' Now you will be able to call the Browse for folder dialog by using the following line of code from your program: Private Sub Form_Load() Dim myDir As String myDir = GetBrowseDirectory(Form1) MsgBox myDir End Sub ...where form1 is the form that will recieve all errormessages. myDir will hold the directory selected or "" (nothing) if selection is cancelled. Last edited by cleverpig : September 16th, 2003 at 12:18 AM. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Get Folder |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|