How to unzip a file by a keyword

NILUSHA MADUMAL

New Member
Joined
Sep 29, 2018
Messages
10
Hi All

I need to unzip a file by a keyword of a file since the file name contents some variable numbers and dates which are varied with the date.

Therefore I tried to create a code to unzip a file by its keyword. I tried to use a function with a sub but it does not respond me. How do I fix this problem?

Code:
[COLOR=#101094][FONT=Consolas][FONT=inherit]Sub[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit] UnZipFile[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit]()[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit]

entUnZipFile [/FONT][/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas][FONT=inherit]"C:\Reports\Monthly.zip"[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit],[/FONT][/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas][FONT=inherit]"D:\Records\Quality"[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit],[/FONT][/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas][FONT=inherit]"*QualityCost*"[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit]&[/FONT][/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas][FONT=inherit]".csv"[/FONT][/FONT][/COLOR][COLOR=#858C93][FONT=Consolas][FONT=inherit]'Filename is "15256_20180625 QualityCost-5.csv"' [/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit]

[/FONT][/FONT][/COLOR][COLOR=#101094][FONT=Consolas][FONT=inherit]End[/FONT][/FONT][/COLOR][COLOR=#101094][FONT=Consolas][FONT=inherit]Sub[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit]


[/FONT][/FONT][/COLOR][COLOR=#101094][FONT=Consolas][FONT=inherit]Function[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit] entUnZipFile[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit]([/FONT][/FONT][/COLOR][COLOR=#101094][FONT=Consolas][FONT=inherit]ByVal[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit] strZipFilename[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit],[/FONT][/FONT][/COLOR][COLOR=#101094][FONT=Consolas][FONT=inherit]ByVal[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit] strDstDir[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit],[/FONT][/FONT][/COLOR][COLOR=#101094][FONT=Consolas][FONT=inherit]ByVal[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit] strFilename[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit])[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit]

[/FONT][/FONT][/COLOR][COLOR=#101094][FONT=Consolas][FONT=inherit]Const[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit] glngcCopyHereDisplayProgressBox [/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit]=[/FONT][/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas][FONT=inherit]256[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit]

[/FONT][/FONT][/COLOR][COLOR=#101094][FONT=Consolas][FONT=inherit]Dim[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit] intOptions[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit],[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit] objShell[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit],[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit] objSource[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit],[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit] objTarget

[/FONT][/FONT][/COLOR][COLOR=#101094][FONT=Consolas][FONT=inherit]Set[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit] objShell [/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit]=[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit] CreateObject[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit]([/FONT][/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas][FONT=inherit]"Shell.Application"[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit])[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit]
[/FONT][/FONT][/COLOR][COLOR=#101094][FONT=Consolas][FONT=inherit]Set[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit] objSource [/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit]=[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit] objShell[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit].[/FONT][/FONT][/COLOR][COLOR=#101094][FONT=Consolas][FONT=inherit]Namespace[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit]([/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit]strZipFilename[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit]).[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit]Items[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit].[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit]Item[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit]([/FONT][/FONT][/COLOR][COLOR=#101094][FONT=Consolas][FONT=inherit]CStr[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit]([/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit]strFilename[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit]))[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit]

[/FONT][/FONT][/COLOR][COLOR=#101094][FONT=Consolas][FONT=inherit]Set[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit] objTarget [/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit]=[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit] objShell[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit].[/FONT][/FONT][/COLOR][COLOR=#101094][FONT=Consolas][FONT=inherit]Namespace[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit]([/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit]strDstDir[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit])[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit]

intOptions [/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit]=[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit] glngcCopyHereDisplayProgressBox

objTarget[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit].[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit]CopyHere objSource[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit],[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit] intOptions

[/FONT][/FONT][/COLOR][COLOR=#101094][FONT=Consolas][FONT=inherit]Set[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit] objSource [/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit]=[/FONT][/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas][FONT=inherit]Nothing[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit]
[/FONT][/FONT][/COLOR][COLOR=#101094][FONT=Consolas][FONT=inherit]Set[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit] objTarget [/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit]=[/FONT][/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas][FONT=inherit]Nothing[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit]
[/FONT][/FONT][/COLOR][COLOR=#101094][FONT=Consolas][FONT=inherit]Set[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit] objShell [/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit]=[/FONT][/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas][FONT=inherit]Nothing[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit]

entUnZipFile [/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit]=[/FONT][/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas][FONT=inherit]1[/FONT][/FONT][/COLOR][COLOR=#303336][FONT=Consolas][FONT=inherit]

[/FONT][/FONT][/COLOR][COLOR=#101094][FONT=Consolas][FONT=inherit]End[/FONT][/FONT][/COLOR][COLOR=#101094][FONT=Consolas][FONT=inherit]Function[/FONT][/FONT][/COLOR]
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Forum statistics

Threads
1,214,829
Messages
6,121,827
Members
449,051
Latest member
excelquestion515

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