Hi,
I found this script on the internet and am using it to unzip a file, but I get a confirmation button to press if the file is already there.
I either need to delete the zip file first, if there is one, or dont have the confirmation screen, how do I go about that?
Sub TestRun()
'Change this as per your requirement
Call UnZip("C:\Users\NeilWin7DB\Trading\ExcelFiles\", "C:\Users\NeilWin7DB\Trading\ExcelFiles\Historical_NAV_Outstanding_AUM.zip")
End Sub
Sub UnZip(strTargetPath As String, fname As Variant)
Dim oApp As Object, FSOobj As Object
Dim FileNameFolder As Variant
If Right(strTargetPath, 1) <> Application.PathSeparator Then
strTargetPath = strTargetPath & Application.PathSeparator
End If
FileNameFolder = strTargetPath
'create destination folder if it does not exist
Set FSOobj = CreateObject("Scripting.FilesystemObject")
If FSOobj.FolderExists(FileNameFolder) = False Then
FSOobj.CreateFolder FileNameFolder
End If
Set oApp = CreateObject("Shell.Application")
oApp.Namespace(FileNameFolder).CopyHere oApp.Namespace(fname).items
Set oApp = Nothing
Set FSOobj = Nothing
Set FileNameFolder = Nothing
End Sub
I found this script on the internet and am using it to unzip a file, but I get a confirmation button to press if the file is already there.
I either need to delete the zip file first, if there is one, or dont have the confirmation screen, how do I go about that?
Sub TestRun()
'Change this as per your requirement
Call UnZip("C:\Users\NeilWin7DB\Trading\ExcelFiles\", "C:\Users\NeilWin7DB\Trading\ExcelFiles\Historical_NAV_Outstanding_AUM.zip")
End Sub
Sub UnZip(strTargetPath As String, fname As Variant)
Dim oApp As Object, FSOobj As Object
Dim FileNameFolder As Variant
If Right(strTargetPath, 1) <> Application.PathSeparator Then
strTargetPath = strTargetPath & Application.PathSeparator
End If
FileNameFolder = strTargetPath
'create destination folder if it does not exist
Set FSOobj = CreateObject("Scripting.FilesystemObject")
If FSOobj.FolderExists(FileNameFolder) = False Then
FSOobj.CreateFolder FileNameFolder
End If
Set oApp = CreateObject("Shell.Application")
oApp.Namespace(FileNameFolder).CopyHere oApp.Namespace(fname).items
Set oApp = Nothing
Set FSOobj = Nothing
Set FileNameFolder = Nothing
End Sub