Consulting

Page 2 of 2 FirstFirst 1 2
Results 21 to 25 of 25

Thread: Excel VBA folder-search-tool

  1. #21
    VBAX Regular
    Joined
    Dec 2021
    Posts
    42
    Location
    Hi again,

    Nice and easy date sorting! Great! ... I remember that I've seen it on your webpage, the link in post #6.

    Maybe you misunderstood me?
    If the path was removed in the result in LB_001 and only had the number (XXXXX) + _ + Rev.index (%) + extension (PDF), it wouldn't be that "confusing" to overview and look at for the user? like this:
    76543_A.pdf
    76543_B.pdf
    76543_A.dxf
    76543_B.dxf

    instead of this view:
    H:\PDF\76543_C.pdf
    H:\PDF\OLD-files\76543_B.pdf
    H:\PDF\OLD-files\76543_A.pdf
    H:\DXF\76543_C.DXF
    H:\DXF\OLD-files\76543_B.DXF
    H:\DXF\OLD-files\76543_A.DXF

    But maybe it would be too difficult to code as the link to file isn't represented any longer(???)

    ...and yes, it would be possible that a file with the exact same name could be represented more than once... (but then of course in different folders)

    Hope it makes sense?

  2. #22
    VBAX Regular
    Joined
    Dec 2021
    Posts
    42
    Location
    Hmm... I've been trying a lot in order to isolate the filename from the path, but nothing works.

        If Len(T_001) = 5 Then
        OptionButton1.Value = True
          History = T_001.Value
          ActiveSheet.Range("A1").Select
          Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromRight 'OrAbove
          Sheets("Sheet1").Range("A1") = History
          
          st = Filter(sn, T_001, , 1)
          'st = Mid$(Filter(sn, T_001, , 1), InStrRev(Filter(sn, T_001, , 1), "\") + 1, Len(Filter(sn, T_001, , 1)))    ' doesn't work!!
          If UBound(st) > -1 Then
            'LB_001.List = st                                                          ' This works, but displays the entire path
            LB_001.List = Mid$(st, InStrRev(st, "\") + 1, Len(st))     ' This doesn't either!!
    
    
          Else
            LB_001.List = Array("                  (   no file found   )")
          End If

    A. Would it be possible to isolate the filename from the path?

    B. Could the listed files in LB_001 be transferred to another listbox (LB_005) if the list only contains the filename and not the path (and later added to an email)?

    C. If B = No, should I then cheat and have two listboxes LB_001 and LB_002 which contain the same results... so if I pick listindex 3 in LB_001 it actually just moves listindex 3 from LB_002 to LB_005
    LB_001 = Only the filename
    LB_002 = file name incl. path (this listbox can't be seen/isn't visible on the Userform)


    I'd be happy to have your comments

  3. #23
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    Although we need the fullpath to assess its size and to add it as an attachment....
    It's rather straightforward:
    Attached Files Attached Files

  4. #24
    VBAX Newbie
    Joined
    Aug 2023
    Posts
    2
    Location
    Certainly! To remove the path from file names displayed in a listbox, you can use string manipulation functions to extract only the file names. Here's a high-level idea in pseudocode:
    python

    for each file in listbox:
    extract file name from file path
    add the file name to the listbox


    To filter files based on typed figures in a textbox, you can implement a filtering mechanism as follows:
    python

    typed_text = get_text_from_textbox()

    for each item in listbox:
    if item starts with typed_text:
    show the item in the listbox
    else:
    hide the item in the listbox


    This code will display files in the listbox that start with the typed figures in the textbox. You would need to implement these concepts in your specific programming language and framework.youtube vanced

  5. #25
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,726
    Location
    @Robert2 --

    Welcome to VBAexpress. Please take a minute to read the FAQ at the limk in my signature

    Also, since many people do not bother to mark the issue as [SOLVED] I recommend that someone who wishes to offer a solution or ask a follow on question check first ot see how old the thread is so you don't waste your time

    However #1 - since the threads are search-able, additional information might be potentially helpful

    However #2 - if someone finds an thread (esp an old one) that allpies to their question, it's usually much better to start a new thread and just reference to old one
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Posting Permissions

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