Consulting

Results 1 to 5 of 5

Thread: Getting filenames of Zipped Folders

  1. #1
    VBAX Newbie
    Joined
    Sep 2005
    Posts
    2
    Location

    Getting filenames of Zipped Folders

    Excel will not find any .zip files and search for the name in variable "kerrymatch".

    If I rename the files to .txt in the subfolder, it finds them.

    Any ideas?

    -CompuRob

    [VBA] Do While master.Cells(masterRow, 3) <> ""
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '
    With Application.FileSearch
    .NewSearch
    .LookIn = "S:\Kerry\packages\"
    .SearchSubFolders = True
    .Filename = kerrymatch
    .MatchTextExactly = False
    .FileType = msoFileTypeAllFiles

    If .Execute() <> 0 Then
    master.Cells(masterRow, 4).Select
    Selection.Interior.ColorIndex = 6
    Selection.Pattern = xlSolid
    MsgBox ("FOUND")

    masterRow = masterRow + 1
    kerrymatch = master.Cells(masterRow, 3)

    Else
    master.Cells(masterRow, 4) = "Not Found"

    masterRow = masterRow + 1
    kerrymatch = master.Cells(masterRow, 3)
    End If
    End With
    Loop
    [/VBA]

  2. #2
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location
    Hmmm... it doesn't work does it?
    Maybe we're missing something obvious but I suspect this might because since M$ hijacked the ZIP format, the whole world has to regard them as "compressed folders" rather than files - XP certainly does and Excel's Filesearch seems to be playing along.
    Luckily, M$'s 3rd law of inconsistency means that the DIR command and the FileSystemObject wouldn't know a "compressed folder" if one extracted itself from inside their abdomen and burst out of their chest, so you can use one of them.
    Here's a FileSystemObject example[VBA]Dim fso, fldr, f

    Set fso = CreateObject("Scripting.FileSystemObject")
    Set fldr = fso.GetFolder("C:\Documents and Settings\Killian\Desktop")
    For Each f In fldr.Files
    If Right(f.Name, 4) = ".zip" Then
    MsgBox "Yay! A zip FILE!"
    End If
    Next[/VBA]
    K :-)

  3. #3
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Hi and Welcome to VBAX!

    Or use the VBA Dir function to do this:[vba]
    Sub FindZip()
    Dim sFile As String
    Dim sPath As String
    sPath = "C:\Documents and Settings\Joost Verdaasdonk\Bureaublad\"
    sFile = Dir(sPath & "*.zip", vbNormal)

    Do Until sFile = ""
    MsgBox "Yeah..:" & vbCr & sPath & sFile & vbCr & _
    "Is a Zip File", vbExclamation, "Zip Files"

    sFile = Dir()
    Loop

    End Sub
    [/vba]

    HTH,
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

  4. #4
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location
    Oh yes, first post and I forgot to welcome you

    Welcome! Hope you're enjoying it so far...
    K :-)

  5. #5
    VBAX Newbie
    Joined
    Sep 2005
    Posts
    2
    Location
    Hey guys - thanks for the responses.

    I found that if you enter these two lines before the routine Zip files are located with no problem:

    result = Shell("regsvr32 /u cabview.dll /s", vbHide)
    result = Shell("regsvr32 /u zipfldr.dll /s", vbHide)

    -Rob

Posting Permissions

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