I have this code and not sure it is not extracting the files. no error giving me msgbox.
Idea is simple to extra all the files from the .gz (screen shot attached)
Idea is simple to extra all the files from the .gz (screen shot attached)
VBA Code:
Sub ExtractDataExportFilesWithWinRAR()
' Define the destination path, folder name, and extraction command
Dim destinationPath As String
Dim folderName As String
Dim fileName As String
Dim extractCommand As String
' Specify the destination path where you want to extract the files
destinationPath = ThisWorkbook.Path & "\" & "NAF Extra File" ' You can change this to your desired destination path
' Specify the folder name that contains files with "DataExport" in their names
folderName = "NAF Extra File"
' Iterate through files in the destination folder
fileName = Dir(destinationPath & "*.gz")
' Loop through each file
Do While fileName <> ""
' Check if the file name contains "DataExport"
If InStr(1, fileName, folderName, vbTextCompare) > 0 Then
' Specify the command to extract the file using WinRAR
extractCommand = "WinRAR x """ & destinationPath & fileName & """ """ & destinationPath & """"
' Print the extraction command to the Immediate Window for debugging
Debug.Print "Extraction Command: " & extractCommand
' Execute the extraction command
Call Shell(extractCommand, vbHide)
' Print a message indicating that the file is being extracted
Debug.Print "Extracting file: " & fileName
End If
' Get the next file in the destination folder
fileName = Dir
Loop
' Print a message indicating that the extraction process is complete
MsgBox "Extraction completed successfully!"
End Sub