03. september 2006 - 18:37Der er
10 kommentarer og 1 løsning
Åbn mapper med commondialog
Hej Eksperter.
Hvordan får man commondialog til at åbn mapper? Altså så at man kan vælge en mappe inde i commondialog og trykke 'Åbn' og så kan jeg bruge den sti i mit program.
Eller kan det evt. gøres på en anden måde?
Håber i forstår hvad jeg mener - ellers så spørgs endelig!
Jeg bruger denne i Excel vbam den skal i et modul.
' ************************ STIFINDER PROGRAMMET`S START ******************** Private 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
Private Declare Function SHGetPathFromIDList Lib "Shell32.dll" Alias _ "SHGetPathFromIDListA" (ByVal pidl As Long, _ ByVal pszPath As String) As Long
Private Declare Function SHBrowseForFolder Lib "Shell32.dll" Alias _ "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) _ As Long
Private Const BIF_RETURNONLYFSDIRS = &H1 Public Function BrowseFolder(szDialogTitle As String) As String Dim X As Long, bi As BROWSEINFO, dwIList As Long Dim szPath As String, wPos As Integer
With bi .hOwner = hWndAccessApp .lpszTitle = szDialogTitle .ulFlags = BIF_RETURNONLYFSDIRS End With
If X Then wPos = InStr(szPath, Chr(0)) BrowseFolder = Left$(szPath, wPos - 1) Else BrowseFolder = "" End If End Function ' ************************ STIFINDER PROGRAMMET`S SLUT ********************
Det hele kaldes sådan
Public Sub FindSti() MinSti = BrowseFolder("Vælg stien til dine filer") End Sub
' ************************ STIFINDER PROGRAMMET`S START ******************** Private 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
Private Declare Function SHGetPathFromIDList Lib "Shell32.dll" Alias _ "SHGetPathFromIDListA" (ByVal pidl As Long, _ ByVal pszPath As String) As Long
Private Declare Function SHBrowseForFolder Lib "Shell32.dll" Alias _ "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) _ As Long
Private Const BIF_RETURNONLYFSDIRS = &H1 Public Function BrowseFolder(szDialogTitle As String) As String Dim X As Long, bi As BROWSEINFO, dwIList As Long, hWndAccessApp As Long Dim szPath As String, wPos As Integer
With bi .hOwner = hWndAccessApp .lpszTitle = szDialogTitle .ulFlags = BIF_RETURNONLYFSDIRS End With
If X Then wPos = InStr(szPath, Chr(0)) BrowseFolder = Left$(szPath, wPos - 1) Else BrowseFolder = "" End If End Function ' ************************ STIFINDER PROGRAMMET`S SLUT ********************
Og denne i formen
Private Sub Command1_Click() Dim MinSti As String MinSti = BrowseFolder("Vælg stien til dine filer") Text1.Text = MinSti End Sub
oki - det er bare herligt! Jeg fortsætter med programmeringen :-)
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.