0

Does a folder need to be unzipped in order for a macro to access its files? I am trying to move files from a zipped file to their respective folder and would like to know if the folder needs to be unzipped for a File System Object to copy it. Thanks

David Podolak
  • 195
  • 2
  • 10
  • 1
    The easiest way to find out is to try it, but the answer is no. – W-hit Mar 15 '19 at 19:16
  • I hope this old link can help you:
    [Can Windows' built-in ZIP compression be scripted?](https://stackoverflow.com/questions/30211/can-windows-built-in-zip-compression-be-scripted/124775#124775)
    – busybyte Mar 15 '19 at 19:27
  • A good resource for this: https://www.rondebruin.nl/win/section7.htm Basically you can do what you want but I don't think you can use FSO to do it. – Tim Williams Mar 15 '19 at 19:32
  • Thanks for the input! – David Podolak Mar 19 '19 at 14:46

1 Answers1

0
Sub MoveFiles()
    Dim FSO As Object
    Dim SourceFileName As String, DestinFileName As String

    Set FSO = CreateObject("Scripting.Filesystemobject")

    SourceFileName = Sheets("NIS File Allocation").Cells(2, 2).Value
    DestinFileName = Sheets("NIS File Allocation").Cells(2, 7).Value
    MsgBox FSO.FileExists(SourceFileName)


    Call FSO.CopyFile(SourceFileName, DestinFileName, False)

    MsgBox (SourceFileName + " Copied to " + DestinFileName)

End Sub

When running this code, SourceFileName must be in an unzipped folder in order to copy it to the destination file. Otherwise a "Path Not Found" Error will result. Tested with .FileExists

David Podolak
  • 195
  • 2
  • 10