Avatar billede silverback Nybegynder
10. februar 2004 - 20:46 Der er 8 kommentarer og
2 løsninger

Button til at åbne en mappe med andre filer

De herrer

Er der nogen nem måde at åbne en specifik mappe via en Button?

Jeg skal bruge det til at linke et hyperlink til en fil. Alle hyperlink'ene referer til forklarende word dokumenter i en mappe /data/.

Det er for at undgå at "gennemse" for at finde filerne.

Med venlig hilsen

Henrik
Avatar billede terry Ekspert
10. februar 2004 - 20:50 #1
you can use the common dialog control (file Open) for doing this. I'm sure it is possible to open at a specific folder!
Avatar billede terry Ekspert
10. februar 2004 - 20:53 #2
You can also download this "add-on" http://www.mvps.org/access/downloads/Explorer.zip

and then alter the start-up folder so that it opend in data
Avatar billede terry Ekspert
10. februar 2004 - 20:56 #3
to open at a specific folder alter Form_Open to>

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
   
End Sub
Avatar billede silverback Nybegynder
10. februar 2004 - 21:42 #4
Thanks Terry it has gotten my mind working. Are you able to elaborate on your first option..the common dialog control.

Thanks in advance

Henrik
Avatar billede terry Ekspert
10. februar 2004 - 21:46 #5
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.

http://www.mvps.org/access/api/api0001.htm
Avatar billede terry Ekspert
10. februar 2004 - 21:51 #6
thanks, hope you can get something to work, now I'm off for some TV :o)
Avatar billede silverback Nybegynder
10. februar 2004 - 21:51 #7
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.

Henrik
10. februar 2004 - 21:58 #8
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")

eller

msgbox BrowseFolder("Angiv mappe")
Avatar billede terry Ekspert
11. februar 2004 - 12:50 #9
Hi Thomas,

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?
Avatar billede silverback Nybegynder
11. februar 2004 - 22:45 #10
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)
Avatar billede Ny bruger Nybegynder

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.

Loading billede Opret Preview
Kategori
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester