JosephMcCain
New Member
- Joined
- Jan 30, 2015
- Messages
- 8
Can someone please let me know what is wrong with the code below?
I am trying to unzip a file using winzip64 and I also want to overwrite any existing files that are extracted.
Currently the code runs without errors but it also doesn't extract the file to the location.
I am trying to unzip a file using winzip64 and I also want to overwrite any existing files that are extracted.
Currently the code runs without errors but it also doesn't extract the file to the location.
Code:
Sub Unzip_With_Overwrite()
Application.DisplayAlerts = False
Dim Cur_Date As Date
Dim fs As Object
Dim Fname As Variant
Dim availableWinzipProgram As String
Dim DefPath As String
Dim Filename As String
Dim latestFile As Variant
Windows("Workbook.xlsm").Activate
Application.Calculate
Cur_Date = Workbooks("Workbook.xlsm").Worksheets("Sheet1").Range("A1").Value
DefPath = "C:\Users\User\Desktop\New Folder\"
Filename = Dir(DefPath & "*" & Format(Cur_Date, "MMM") & "*.zip", vbNormal)
Do While Filename <> ""
If FileDateTime(DefPath & Filename) > dtLast Then
dtLast = FileDateTime(DefPath & Filename)
latestFile = DefPath & Filename
End If
Filename = Dir
Loop
Filename = Dir$(latestFile)
Fname = DefPath & Filename
Set fs = CreateObject("Scripting.FileSystemObject")
availableWinzipProgram = "C:\Program Files\WinZip\WINZIP64.EXE"
shellString = availableWinzipProgram & " -e -o " & Fname & " " & DefPath
Application.DisplayAlerts = True
End Sub