@sync2018: Kindly find the working code below as per your requirement and fine tune it if there is a need for any further modification. Kindly let me know if any further help is needed
Note: This is a working code and unwanted variable or operations might be present
WorkingDir = "Add the path of the directory where the files are present should be zipped" for eg.,"C:\Users\U465205\Desktop\alpa_code\"
zipfile = "Give the path where the zip file should be saved with the file name as well ends with zip extension" for eg.,"C:\Users\U465205\Desktop\alpa_code\mulla.zip"
Extension = ".csv"
Dim fso, myFolder, fileColl, aFile, FileName, SaveName
Dim objExcel, objWorkbook
Set fso = CreateObject("Scripting.FilesystemObject")
savedir=WorkingDir&"New Folder"
If Not fso.FolderExists(savedir&"\") Then
fso.CreateFolder savedir&"\"
End If
Set myFolder = fso.GetFolder(WorkingDir)
Set fileColl = myFolder.Files
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = False
objExcel.DisplayAlerts = False
For Each aFile In fileColl
ext = Right(aFile.Name,Len(Extension))
If UCase(ext) = UCase(extension) Then
fso.CopyFile aFile , savedir &"\"
End If
Next
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.OpenTextFile(zipfile, 2, True).Write "PK" & Chr(5) & Chr(6) & String(18, Chr(0))
Set ShellApp = CreateObject("Shell.Application")
Set zip = ShellApp.NameSpace(zipfile)
zip.CopyHere savedir
WScript.Sleep 10000
Set objWorkbook = Nothing
Set objExcel = Nothing
Set myFolder = Nothing
Set fileColl = Nothing
Set fso = Nothing
set objFolder = nothing
set objShell = nothing
Set ts = nothing