vba code to select file and unzip files in a different folder with different name

karthikha0706

New Member
Joined
Oct 30, 2013
Messages
45
HI All, Am looking for a vba code to select a file from a folder and unzip the file in a different folder with different file name. Can you please assist me with the code.
Thanks in advance.
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Hi,​
first well elaborate with details your need in order there is nothing to guess …​
 
Upvote 0
VBA Code:
Option Explicit

Sub UnzipAFile(zippedFileFullName As Variant, unzipToPath As Variant)

Dim ShellApp As Object

'Copy the files & folders from the zip into a folder
Set ShellApp = CreateObject("Shell.Application")
ShellApp.Namespace(unzipToPath).CopyHere ShellApp.Namespace(zippedFileFullName).items

End Sub


'To call the procedure above the following code can be used within another procedure.  Change the paths to be the name of the zip file you wish to unzip and the folder you wish to put the unzipped files into.
Sub UnzipFileToFolder()
    Call UnzipAFile("C:\Users\jimga\Desktop\Magnifier2.zip", "C:\Users\jimga\Desktop\UnzipHereFolder\")
    Name "C:\Users\jimga\Desktop\UnzipHereFolder\magnifier.exe" As "C:\Users\jimga\Desktop\UnzipHereFolder\Magnifier.exe"
End Sub

Edit paths as required.
 
Upvote 0
Hi,​
first well elaborate with details your need in order there is nothing to guess …​
HI Marc, I usually download 3 zip files daily from a website and save it in a folder named Download and the name of these files are changed everyday, i need a code to unzip the 3 files into a folder named XYZ with below names.

File 1 in the name of Jan
File 2 in the name of feb
File 3 in the name of Mar
 
Upvote 0
HI Marc, I usually download 3 zip files daily from a website and save it in a folder named Download and the name of these files are changed everyday, i need a code to unzip the 3 files into a folder named XYZ with below names.

File 1 in the name of Jan
File 2 in the name of feb
File 3 in the name of Mary
HI Marc, as i said in the query, my 3 zip file names are changing daily, i can use the code given by Logit if my zip file names are constant.
 
Upvote 0
So what is your strategy ?!​
Daily 3 zip files (file name gets changed every day)am downloading in a specific folder C:\download. Each zip file contains one csv file. i am looking for a VBA code to run daily that unzip the 3 files and save it in a folder named c:\XYZ with below file names.

unzipfile 1 and rename file abc.csv as xyz.csv
unzipfile 2 and rename file abc1.csv as xyz1.csv
unzipfile 3 and rename file abc2.csv as xyz2.csv
 
Upvote 0
Unclear as you wrote « the name of these files are changed everyday » so how can be determined 'file 1' to 'file 3' ?​
 
Upvote 0
Unclear as you wrote « the name of these files are changed everyday » so how can be determined 'file 1' to 'file 3' ?​
Hi Marc, For example. today i downloaded from web the following 3 zipfiles.

1. abc060721.zip which contains abc060721.csv file
2. def060721.zip which contains def060721.csv file
3. ghi060721.zip which contains ghi060721.csv file

I would like to unzip the above files and save it without date in the file . For ex. abc060721.csv file as abc.csv and def060721.csv file as def.csv and ghi060721.csv file as ghi.csv.

Tomorrow, again i will download from web the below 3 zip files and do the same process.
1. abc070721.zip which contains abc070721.csv file
2. def070721.zip which contains def070721.csv file
3. ghi070721.zip which contains ghi070721.csv file

I would like to unzip the above files and save it without date in the file . For ex. abc070721.csv file as abc.csv and def070721.csv file as def.csv and ghi070721.csv file as ghi.csv.



I hope this is clear to understand my requirement.
 
Upvote 0
So each of your real text filename starts with only 3 letters and forever, never be changed ?​
 
Upvote 0

Forum statistics

Threads
1,214,588
Messages
6,120,409
Members
448,959
Latest member
camelliaCase

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top