0

Having difficulty getting multi unzip to work with a custom file name. Below is the code, any suggestions greatly appreciated. Have tried GetOpenFilename with no success. The point of where the error occurs is marked below:

Option Explicit
Sub UnzipSelectFiles()
    Dim xFileSelect As Variant
    Dim xSelectedItem As Variant
    Dim xFilePath As String
    Dim strDate As String
    Dim xFileNameFolder As Variant
    Dim xApp As Object

'    Set xFileSelect = Application.GetOpenFilename(filefilter:="Zip Files (*.zip), *.zip", _
    MultiSelect:=True)

    Set xFileSelect = Application.FileDialog(msoFileDialogOpen)

    With xFileSelect
        .AllowMultiSelect = True
        .Title = "Select ZIP Compressed Files"
        .Filters.Clear
        .Filters.Add "Zip Compressed Files", "*.zip"
        .InitialView = msoFileDialogViewDetails

        If xFileSelect.Show = -1 Then
            For Each xSelectedItem In xFileSelect.SelectedItems
                xFilePath = xSelectedItem
                strDate = Format(Now, " mmm-dd-yyyy hh_mm_ss AMPM")
                xFileNameFolder = xFilePath & strDate & "\"
                Debug.Print xFileNameFolder
                MkDir xFileNameFolder

                Set xApp = CreateObject("Shell.Application")

                '~~~~>
                'Runtime error #91 Object variable or with block variable not set
                xApp.Namespace(xFileNameFolder).CopyHere xApp.Namespace(xFileSelect).Items
                '~~~~>

                Next xSelectedItem
            End If
        End With
        Set xApp = Nothing
    End Sub
Jchang43
  • 891
  • 6
  • 14
Tahor Sui Juris
  • 131
  • 1
  • 12

0 Answers0