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

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
So each of your real text filename starts with only 3 letters and forever, never be changed ?​
Yes Marc. Your understanding is correct. Also, i would like to overwrite the 3 csv files daily when i unzip the files in a particular folder.
 
Upvote 0
So each zip file contains a single text file only which has always the same name as the zip file ?​
 
Upvote 0
So each zip file contains a single text file only which has always the same name as the zip file ?​
Yes Marc. However date is attached to the zip file . For example today i will get the file as ABC070721.zip and tomorrow ABC080721.zip and so on....
 
Upvote 0
Last option : once a file extracted and renamed should its zip container be deleted from the source folder ?​
 
Upvote 0
Last question as there are different ways : is the destination folder C:\XYZ always empty (or without any .csv text file) before the zip extraction ?​
 
Upvote 0
Forget previous question, just answer to post #15 …​
 
Upvote 0
A VBA demonstration for starters :​
VBA Code:
Sub DemoUnZip1()
      Const D = "C:\XYZ\", S = "C:\Download\", C = ".csv"
        Dim Z$, oSh As Object, F$, N$
    With CreateObject("Scripting.FileSystemObject")
            Z = Dir$(S & "*.zip"):  If Z = "" Or Not .FolderExists(D) Then Beep: Exit Sub
            Set oSh = CreateObject("Shell.Application")
        Do
               F = oSh.NameSpace(S & Z).Items.Item(0).Name
            If F Like "???######" & C Then
                oSh.NameSpace(D).CopyHere oSh.NameSpace(S & Z).ParseName(F), 16
                N = D & Left$(F, 3) & C:  If .FileExists(N) Then .DeleteFile N, True
               .MoveFile D & F, N
               .DeleteFile S & Z, True
            End If
                   Z = Dir$
        Loop Until Z = ""
             Set oSh = Nothing
    End With
End Sub
 
Upvote 0
Last question as there are different ways : is the destination folder C:\XYZ always empty (or without any .csv text file) before the zip extraction ?​
No Marc. The destination folder XYZ contains other csv files.....and previous days extraction of
Forget previous question, just answer to post #15 …​
Last question as there are different ways : is the destination folder C:\XYZ always empty (or without any .csv text file) before the zip extraction ?​
No Marc. The destination folder XYZ contains other csv files.....and previous days extraction of abc.csv, def.csv and ghi.csv
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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