Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2002
    Location
    Cambridge, England
    Posts
    47

    Question Unanswered: Browse Folder default value

    Hi

    Does anyone know how I can use a 'Browse-Folder' dialog which will let me set a default value, and maybe the ability to add a new folder? I currently have the Browse Folder code but it opens at the 'Desktop' level every time.

    I am running Access XP and Windows XP

    Thanks

  2. #2
    Join Date
    Sep 2003
    Posts
    17

    Re: Browse Folder default value

    Post your code.
    The path needs to be alterred, It's easier this way.

  3. #3
    Join Date
    Aug 2002
    Location
    Cambridge, England
    Posts
    47
    Option Compare Database

    '************** Code Start **************
    'This code was originally written by Terry Kreft.
    'It is not to be altered or distributed,
    'except as part of an application.
    'You are free to use it in any application,
    'provided the copyright notice is left unchanged.
    '
    'Code courtesy of
    'Terry Kreft

    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

    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

    '*********** Code End *****************

  4. #4
    Join Date
    Sep 2003
    Posts
    17
    I'll look at your code later.

  5. #5
    Join Date
    Sep 2003
    Posts
    17
    Try this link from Microsoft.

    It contains all the info you need.
    You can alter the path within the code to suit your needs.:-

    http://support.microsoft.com/default...b;en-us;303066

  6. #6
    Join Date
    Aug 2002
    Location
    Cambridge, England
    Posts
    47
    Is this editable so I can select a destination 'Folder' and not a file. ALso how can I set the default?

    Thanks for your time

  7. #7
    Join Date
    Sep 2003
    Posts
    17
    Originally posted by nstaward
    Is this editable so I can select a destination 'Folder' and not a file. ALso how can I set the default?

    Thanks for your time
    Heres where you can set the default:

    OpenFile.lpstrInitialDir = "C:\"

    To:

    OpenFile.lpstrInitialDir = "C:\Windows\DeskTop\MyFolder"

    Change the default lookup, JPG in this case to whatever extension you require, DOC, TXT,GIF ............................

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •