carlosanoli
New Member
- Joined
- Jun 5, 2019
- Messages
- 3
Helo everyone,
I am using this code to unzip files:
But instead of let the output folder inside the code, I would like to put it in a cell where other people could easily change the output. Can someone help me to change this code?
Thanks a lot.
I am using this code to unzip files:
Code:
[COLOR=blue][FONT=Raleway]Sub Unzip_Files()[/FONT][/COLOR]
[COLOR=#38761D][FONT=Raleway]' Author: Dreams24[/FONT][/COLOR]
[COLOR=#38761D][FONT=Raleway]' Written for VBA Tricks and tips blog[/FONT][/COLOR]
[COLOR=#38761D][FONT=Raleway]' [URL="https://www.vbatricksntips.com/"]https://www.vbatricksntips.com[/URL][/FONT][/COLOR]
[COLOR=blue][FONT=Raleway]
[/FONT][/COLOR][COLOR=#232323][FONT=Raleway][/FONT][/COLOR][COLOR=#38761D][FONT=Raleway]'Declare Variable[/FONT][/COLOR]
[COLOR=blue][FONT=Raleway] Dim oApp As Object[/FONT][/COLOR]
[COLOR=blue][FONT=Raleway] Dim Fname As Variant[/FONT][/COLOR]
[COLOR=blue][FONT=Raleway] Dim Output_Folder As Variant[/FONT][/COLOR]
[COLOR=blue][FONT=Raleway] Dim strDate As String[/FONT][/COLOR]
[COLOR=blue][FONT=Raleway] Dim i As Long[/FONT][/COLOR]
[COLOR=blue][FONT=Raleway] [/FONT][/COLOR]
[COLOR=#38761D][FONT=Raleway] 'Select multiple zip files to unzip[/FONT][/COLOR]
[COLOR=blue][FONT=Raleway] Fname = Application.GetOpenFilename(filefilter:="Zip Files (*.zip), *.zip", _[/FONT][/COLOR]
[COLOR=blue][FONT=Raleway] MultiSelect:=True)[/FONT][/COLOR]
[COLOR=blue][FONT=Raleway] If IsArray(Fname) = False Then[/FONT][/COLOR]
[COLOR=blue][FONT=Raleway] 'Do nothing[/FONT][/COLOR]
[COLOR=blue][FONT=Raleway] Else[/FONT][/COLOR]
[COLOR=blue][FONT=Raleway] [/FONT][/COLOR]
[COLOR=blue][FONT=Raleway] [/FONT][/COLOR][COLOR=#38761D][FONT=Raleway]'Set output folder path for unzip files[/FONT][/COLOR]
[COLOR=blue][FONT=Raleway] Output_Folder = "C:\Users\Dreams\Desktop\Test_Unzip\Unzip"[/FONT][/COLOR]
[COLOR=blue][FONT=Raleway] [/FONT][/COLOR]
[COLOR=blue][FONT=Raleway] [/FONT][/COLOR][COLOR=#38761D][FONT=Raleway]'Append backslash to output folder path[/FONT][/COLOR]
[COLOR=blue][FONT=Raleway] If Right(Output_Folder, 1) <> "" Then[/FONT][/COLOR]
[COLOR=blue][FONT=Raleway] Output_Folder = Output_Folder & ""[/FONT][/COLOR]
[COLOR=blue][FONT=Raleway] End If[/FONT][/COLOR]
[COLOR=blue][FONT=Raleway]
[/FONT][/COLOR][COLOR=#232323][FONT=Raleway][/FONT][/COLOR][COLOR=blue][FONT=Raleway] [/FONT][/COLOR][COLOR=#38761D][FONT=Raleway] 'Extract the files into output folder[/FONT][/COLOR]
[COLOR=blue][FONT=Raleway] Set oApp = CreateObject("Shell.Application")[/FONT][/COLOR]
[COLOR=blue][FONT=Raleway] For i = LBound(Fname) To UBound(Fname)[/FONT][/COLOR]
[COLOR=blue][FONT=Raleway] [/FONT][/COLOR]
[COLOR=blue][FONT=Raleway] oApp.Namespace(Output_Folder).CopyHere oApp.Namespace(Fname(i)).items[/FONT][/COLOR]
[COLOR=blue][FONT=Raleway]
[/FONT][/COLOR][COLOR=#232323][FONT=Raleway][/FONT][/COLOR][COLOR=blue][FONT=Raleway] Next i[/FONT][/COLOR]
[COLOR=blue][FONT=Raleway]
[/FONT][/COLOR][COLOR=#232323][FONT=Raleway][/FONT][/COLOR][COLOR=blue][FONT=Raleway] MsgBox "You find the files here: " & Output_Folder[/FONT][/COLOR]
[COLOR=blue][FONT=Raleway] [/FONT][/COLOR]
[COLOR=blue][FONT=Raleway] End If[/FONT][/COLOR]
[COLOR=blue][FONT=Raleway] [/FONT][/COLOR]
[COLOR=blue][FONT=Raleway]End Sub[/FONT][/COLOR]
But instead of let the output folder inside the code, I would like to put it in a cell where other people could easily change the output. Can someone help me to change this code?
Thanks a lot.