Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800

    Is There a File Dialog Folder Picker That Shows Files?

    Have been searching all morning. In vba, is there not a folder picker that also shows files but allows you to pick the folder? I suppose I could use the file picker and strip off the file name in the resulting string but that seems like a hack to me. I need to load all the file paths in the chosen folder into a table, but I need to be able to see the files in order to know whether or not they meet the requirements for doing so. In case the reader is not aware and if I'm not mistaken
    - the folder picker doesn't show files
    - the file picker doesn't allow you to choose a folder
    - the Windows file dialog does not allow you to return a folder path



    I'd be willing to use an API if there is one for doing exactly what I need.
    Thanks.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  2. #2
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Application.FileDialog 3 allows you to browse both but only select a File.
    Application.FileDialog shows folders as it expect you to choose one...

    Hmm an interesting conundrum, you could list the folders and files in a couple of list boxes ?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Saw earlier today this thread that seems related, in post #6 the OP there complains about exactly what you're after I think:
    https://www.access-programmers.co.uk...er-coe.323620/
    The code mentioned in there comes from here:
    https://bytes.com/topic/access/insig...edialog-object
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  4. #4
    orange's Avatar
    orange is online now Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Micron,

    "I need to be able to see the files in order to know whether or not they meet the requirements for doing so"

    Not sure what all you have to review to make the determination, but you could, as you have already alluded to, read/save the file path and have a small routine to drop the last slash and file name.
    I guess as usual the devil is in the details.

  5. #5
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    Code:
    Application.FileDialog  3  allows you to browse both but only select a File.
    There's the rub. As noted, I don't want to select a file as that will return the entire path or the file name, depending on how you code it. I only want the parent folder of the file.
    Saw earlier today this thread that seems related, in post #6 the OP there complains about exactly what you're after I think:
    Maybe post 7 or so? Anyway, point 2 from that post is what I want
    2) Shows files as well as Folders. Don't want this
    whereas the OP seems to want the opposite. I will take a look at the code link in post 3 here, but I don't expect it will meet the requirement. The issue with the application dialogs seems to be that one shows only folders and the other shows files, but you cannot choose a folder with it, and your choice can only be a file object - with or without its complete path or just its file name.

    For now I have managed to get the parent folder by using the file picker and hacking the folder name from that. My next problem seems to be being able to modify the ID3 tag properties (Title) of the files in the chosen folder. That might be another thread.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    Well I followed those links and unless I missed something, the standard dialog is being used. That means you can pick a folder but not see the files, or you can see the files but not pick a folder as I mentioned. I'm just going to conclude that it isn't possible to see files and pick a folder instead and get the file path from the resulting string:

    strPath = Left(strPath, InStrRev(strPath, ""))

    Case closed - thanks for the responses.
    Now I have to find ID3 tag editing code (vba) that works for me. I have code that seems to alter the tags but when I look at them with Stamp ID3 Tag Editor software, the code seems to have no effect on the title tag.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    orange's Avatar
    orange is online now Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Micron,
    Glad you have things under control. I wasn't aware there was other software involved.
    Never heard of Stamp ID3 Tag Editor.

  8. #8
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,936
    I use Tag & Rename, but interactively.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  9. #9
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    I think I'm just use Stamp and fix the mp3 titles manually. At least I can do it in batches (all files in a particular folder). As long as the file name is what I want, it can fix a batch of titles by copying the file name. This is all because my car's system doesn't seem to sort songs by file name but by title instead. So the title might be Track 1 and that's what I'll see in the car infotainment screen.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  10. #10
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Media Monkey has (had?) an excellent Renaming thingumy where it would read the tags and then rename the files/tracks as per your desired layout.
    For me that was always track number (With leading zero) , track name so they played in the correct order.

    00 - Trackname

    Not sure if it's still available or still good?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  11. #11
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,936
    Media Monkey is still going. That is my player app on my phone.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  12. #12
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    Good info for anyone who falls here while looking for ID3 tag editor, but I'm going to stick with Stamp since it's free and I can edit title, artist, genre, etc. in a batch operation. Fortunately it is the titles that presents the most of the work I have to do on this. The filenames are good for the most part.
    Last edited by Micron; 06-16-2022 at 11:18 AM. Reason: correction
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  13. #13
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,936
    TBH, I have had my $30 worth out of T&R time and time again.
    I do not even use half the features, mainly the two processes by which it is called.
    I too have my music as
    Code:
    Artist
      Album
        01 - Track Name
        02 - Track Name
    Using masks, it is very quick to update filenames from tags and vice versa.
    All with a few clicks and a few letters entered.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  14. #14
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    I needed this functionality today and found this in my MZTools code library. It's originally from UtterAccess, but apparently their Wiki is not on line currently.
    Note that it requires a UDT, and no API.

    Code:
    ' Code courtesy of UtterAccess Wiki
    ' http://www.utteraccess.com/wiki/index.php/Category:FunctionLibrary
    '
    ' You are free to use this code in any application,
    ' provided this notice is left unchanged.
    '
    '==============================================================================
    ' NAME: GetDirContents
    '
    ' PURPOSE: Retrieves lists and information about contents of a Folder
    '
    ' RETURNS: FOLDERCONTENTS structure
    '          This procedure does not raise an error on an invalid
    '          Folder parameter
    '
    ' ARGUMENTS: sFolder - Folder to evaluate
    '            Delimiter (Optional, default ";") - list delimiter for return
    '
    '
    '
    ' DEPENDANCIES:
    '
    '  The Split() and Replace() functions are required for this procedure.  If
    '  you are using Access 97 or earlier you will need custom versions of these
    '  for this procedure to work.
    '
    '  This structure is required in the declarations section of a standard module
    '  ----------
    '  Public Type FOLDERCONTENTS
    '    dcCount As Long             'number of files and Folders
    '    dcFolder As Long         'number of Folders
    '    dcFiles As String           'delimited list of files
    '    dcFolders As String     'delimited list of Folders
    '    dcReadOnly As Long          'number of read only files
    '    dcHidden As Long            'number of hidden files
    '    dcSystem As Long            'number of system files
    '    dcArchive As Long           'number of files ready for archiving
    '  End Type
    '  ----------
    '
    '  This function includes a call to QSortInPlace.  Because Folder contents
    '  returned from the Dir() function are not sorted, this is used to return
    '  a list that is sorted.
    '
    '  The QSortInPlace function is property of Chip Pearson and can be found at:
    '     http://www.cpearson.com/excel/SortingArrays.aspx
    '
    '  The QSortInPlace call can be commented out with no consequence to the return
    '  of the function other than having the lists of files and Folders sorted
    '  by numerically and alphabetically
    '
    '
    '
    ' EXAMPLE USAGE:
    '  ----------
    '  Sub PrintDirInfo(sDir As String)
    '    Dim dc As FOLDERCONTENTS
    '    dc = GetDirContents(sDir)
    '    With dc
    '      Debug.Print "Folder List: " .dcFolders & vbCrLf
    '      Debug.Print "File List: " & .dcFiles & vbCrLf
    '      Debug.Print "Item Count: " & .dcCount & vbCrLf
    '      Debug.Print "Number of Folders: " & .dcFolder & vbCrLf
    '      Debug.Print "Number of Read Only: " & .dcReadOnly & vbCrLf
    '      Debug.Print "Number of Hidden Files :" & .dcHidden & vbCrLf
    '      Debug.Print "Number of System Files: " & .dcSystem & vbCrLf
    '      Debug.Print "Number of Archive Ready Files: " & .dcArchive & vbCrLf
    '    End With
    '  End Sub
    '  ----------
    '
    '
    ' REVISIONS:
    '  REV |    DATE    | REV TYPE | DESCRIPTION
    '------------------------------------------------------------------------------
    '  R01   2010/09/30    INITIAL
    '  R02   2022/06/18    Enhance  davegri- mod to default extract attribute to vbDirectory,
    '                               to omit system and hidden files.
    '                               Changed some variable names for clarity
    '==============================================================================
    'ErrHandler V3.01
    Public Function GetDirContents(sFolder As String, Optional Delimiter As String = ";") As FOLDERCONTENTS
    On Error GoTo Error_Proc
    Dim Ret As FOLDERCONTENTS
    '=========================
     Dim v As Variant  'variant array to hold returns
     Dim s As String   'string to hold returns
     Dim sT As String  'temp file placeholder
     Dim i As Long     'counter/loop iterator
     Dim lAttr As Long 'attributes placeholder
    '=========================
    
    
     If Right(sFolder, 1) <> "\" Then sFolder = sFolder & "\"
    
    
     'get the complete list
     sT = Dir(sFolder, vbDirectory)
     'sT = Dir(sFolder, vbNormal)
     While sT <> ""
       s = s & ";" & sT
       sT = Dir()
     Wend
     
     If s = "" Then GoTo Exit_Proc
     
     'remove leading delimiter
     s = Right(s, Len(s) - 1)
     
     'remove the "." and ".."
     s = Replace(s, ".;", "", 1, 1)
     s = Replace(s, "..;", "", 1, 1)
     
     'split into the array
     v = Split(s, ";")
     
     'sort the array
    ' QSortInPlace v
     
     'start building the return structure
     
     'get the total count
     Ret.dcCount = UBound(v) + 1
     
     For i = 0 To UBound(v)
       'get the attributes of the item
       lAttr = GetAttr(sFolder & v(i))
       With Ret
       
         If lAttr And vbDirectory Then
           'this item is a Folder
           .dcFolders = .dcFolders & Delimiter & v(i)
           .dcFolder = .dcFolder + 1
         Else
           'this item is a file
           
            .dcFiles = .dcFiles & Delimiter & v(i)
            '.dcFiles = .dcFiles & v(i) & vbCrLf
         End If
         
         'add counts to applicable file properties
         If lAttr And vbArchive Then .dcArchive = .dcArchive + 1
         If lAttr And vbSystem Then .dcSystem = .dcSystem + 1
         If lAttr And vbHidden Then .dcHidden = .dcHidden + 1
         If lAttr And vbReadOnly Then .dcReadOnly = .dcReadOnly + 1
         
       End With
     
     Next
     
     'cleanup the return structure
     '(remove leading delimiter from list strings)
     With Ret
       If .dcFolders <> "" Then
         .dcFolders = Right( _
                         .dcFolders, Len(.dcFolders) - Len(Delimiter))
       End If
       If .dcFiles <> "" Then
         .dcFiles = Right(.dcFiles, Len(.dcFiles) - Len(Delimiter))
       End If
     End With
     
    '=========================
    Exit_Proc:
        GetDirContents = Ret
        Exit Function
    Error_Proc:
        Select Case Err.Number
            Case Else
                MsgBox "Error: " & Trim(Str(Err.Number)) & vbCrLf & _
                "Desc: " & Err.Description & vbCrLf & vbCrLf & _
                "Module: modGetDirContents, Procedure: GetDirContents" _
                , vbCritical, "E r r o r !"
        End Select
     Resume Exit_Proc
     Resume
    End Function

  15. #15
    orange's Avatar
    orange is online now Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    @Davegri,

    Dave, nice function and very quick. I copied your code, left the QSortInPlace commented. The result was immediate and the list was sorted. I'm sure micron will be happy with the function.

    Your mention of MzTools caught my eye. I have used MZTools for several years, but only for line numbering, error and headers, indenting and occasionally for documentation.

    In early June 22 I was looking for info examples or more info on customizing MZTools vba Loop or other code favorites and have had no responses. Do you have any details on how to set up the code library? I wasn't sure if nobody used the feature or if nobody wanted to divulge a their own usage of the product.

    Also, the redesign of UA does not have some of the wiki stuff that was often referenced. Hopefully, some of those will be "re-attached" - they were quite helpful.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Copying files using a file dialog to select them
    By LukeBatty in forum Programming
    Replies: 7
    Last Post: 05-18-2017, 12:04 PM
  2. Replies: 10
    Last Post: 09-09-2015, 03:25 AM
  3. file picker dialog and docmd transfer database table
    By REBBROWN in forum Programming
    Replies: 3
    Last Post: 08-11-2014, 02:12 PM
  4. Replies: 7
    Last Post: 11-20-2012, 05:08 PM
  5. Replies: 21
    Last Post: 08-20-2012, 11:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums