mali10020
New Member
- Joined
- Oct 15, 2021
- Messages
- 17
- Office Version
- 365
- 2010
- Platform
- Windows
- Mobile
Good morning guys!!
please assist if you can!!
I want this code to unzip the latest folder in Dir and copy all the files inside that folder to a different folder and open the bigest file in the folder
Sub Unzip1()
Dim FSO As Object
Dim oApp As Object
Dim Fname As Variant
Dim FileNameFolder As Variant
Dim DefPath As String
Dim strDate As String
Fname = Application.GetOpenFilename(filefilter:="Zip Files (*.zip), *.zip", _
MultiSelect:=False)
If Fname = False Then
'Do nothing
Else
'Root folder for the new folder.
'You can also use DefPath = "C:\Apps\CipherRounds_1633694385.zip"
DefPath = Application.DefaultFilePath
If Right(DefPath, 1) <> "\" Then
DefPath = DefPath & "\"
End If
'Create the folder name
strDate = Format(Now, " dd-mm-yy h-mm-ss")
FileNameFolder = DefPath & "MyUnzipFolder " & strDate & "\"
'Make the normal folder in DefPath
MkDir FileNameFolder
'Extract the files into the newly created folder
Set oApp = CreateObject("Shell.Application")
oApp.Namespace(FileNameFolder).CopyHere oApp.Namespace(Fname).Items
'If you want to extract only one file you can use this:
'oApp.Namespace(FileNameFolder).CopyHere _
'oApp.Namespace(Fname).items.Item("test.txt")
MsgBox "You find the files here: " & FileNameFolder
On Error Resume Next
Set FSO = CreateObject("scripting.filesystemobject")
FSO.DeleteFolder Environ("Temp") & "\Temporary Directory*", True
End If
'ActiveWorkbook.Worksheets("").CopyWorkbooks("Mobile").Worksheets ("Device name")
'ActiveSheet.name = NewestFile.name
Cells.Select
Selection.Copy
Application.DisplayAlerts = False
ActiveWindow.Close
Application.CutCopyMode = False
Application.DisplayAlerts = True
Windows("Mobile.xlsm").Activate
ActiveSheet.Paste
Range("A1").Select
'ActiveSheet.name = NewestFile.name
'Workbooks(NewestFile.Name).Close
End Sub
please assist if you can!!
I want this code to unzip the latest folder in Dir and copy all the files inside that folder to a different folder and open the bigest file in the folder
Sub Unzip1()
Dim FSO As Object
Dim oApp As Object
Dim Fname As Variant
Dim FileNameFolder As Variant
Dim DefPath As String
Dim strDate As String
Fname = Application.GetOpenFilename(filefilter:="Zip Files (*.zip), *.zip", _
MultiSelect:=False)
If Fname = False Then
'Do nothing
Else
'Root folder for the new folder.
'You can also use DefPath = "C:\Apps\CipherRounds_1633694385.zip"
DefPath = Application.DefaultFilePath
If Right(DefPath, 1) <> "\" Then
DefPath = DefPath & "\"
End If
'Create the folder name
strDate = Format(Now, " dd-mm-yy h-mm-ss")
FileNameFolder = DefPath & "MyUnzipFolder " & strDate & "\"
'Make the normal folder in DefPath
MkDir FileNameFolder
'Extract the files into the newly created folder
Set oApp = CreateObject("Shell.Application")
oApp.Namespace(FileNameFolder).CopyHere oApp.Namespace(Fname).Items
'If you want to extract only one file you can use this:
'oApp.Namespace(FileNameFolder).CopyHere _
'oApp.Namespace(Fname).items.Item("test.txt")
MsgBox "You find the files here: " & FileNameFolder
On Error Resume Next
Set FSO = CreateObject("scripting.filesystemobject")
FSO.DeleteFolder Environ("Temp") & "\Temporary Directory*", True
End If
'ActiveWorkbook.Worksheets("").CopyWorkbooks("Mobile").Worksheets ("Device name")
'ActiveSheet.name = NewestFile.name
Cells.Select
Selection.Copy
Application.DisplayAlerts = False
ActiveWindow.Close
Application.CutCopyMode = False
Application.DisplayAlerts = True
Windows("Mobile.xlsm").Activate
ActiveSheet.Paste
Range("A1").Select
'ActiveSheet.name = NewestFile.name
'Workbooks(NewestFile.Name).Close
End Sub