Private Sub Form_Open(Cancel As Integer) Call sFillRoot Me!lblPath.Caption = ""
'To start in specific folder use the following Dim stPath As String stPath = "C:\data" '<<<<<<<<<<<<<<<<<<<< This is the startup folder mboolClick = False: mboolUp = False Call sNavigate(stPath)
If mstPath = vbNullString Then mstFilePath = Left$(Me!lbxFolders, Len(Me!lbxFolders) - 1) Else mstFilePath = mstPath & "\" & Me!lbxFolders End If mboolClick = True: mboolUp = False DoCmd.Hourglass True Me!lbxFiles.Requery DoCmd.Hourglass False
There is control in the toolbox called the common dialog control, but when I come to think about it, I dont think it comes with Office normally. Here is a link to an alternative, although if your not good at programming it may be a mouth full.
Holy... well I am not a quitter but I must admit that that is more than a mouthfull :-) As you have guessed I have only limited experience with code. And what is left is from way back when. Anyway thanks I better start digging into the matter.
Spørgsmålet er godt nok lukket, men jeg synes selv, at denne simple kode er både kønnere og mere elegant. Læg denne kode i et modul:
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 = 81 End With dwIList = SHBrowseForFolder(bi) szPath = Space$(512) X = SHGetPathFromIDList(ByVal dwIList, ByVal szPath)
If X Then wPos = InStr(szPath, Chr(0)) BrowseFolder = Left$(szPath, wPos - 1) Else BrowseFolder = "" End If End Function
Kør herefter denne kode fra f.eks. en knap: Me!Mappe = BrowseFolder("Angiv mappe")
If its only the folder name that Henrik is after then this is obviously the easiest method, but I was under the impression that he wanted to open the folder to retrieve Word document names.
Can you tell us exactly what it is yor after Henrik and maybve we can make further suggestions?
I am sorry gentlemen I seem to give rather bad directions.
With a button I what to be able to open a folder, preselected by myself, instead of having to browse through the foldertree.
I what to use it in comibnation with selecting a hyperlink, so:
I write info in my database and for each entry I press a button to link it with a larger document. With my present procedure I have to browse to the folder with my documents and then choose the one for the hyperlink. It would be easier if the button opened the folder with the documents directly.
I am not sure if this makes sense and perhaps this has to be another points question, but here you have it.
Sorry for any fog! And thanks for the help sofare (any correcting help is very welcome)
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.