compressing file

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Good day.

Is it possible to write a batch file or is there some VBA code that anyone
knows to zip or compress a file using the XP compression?

Thanks,
 
CreateBlankZip.vbs
CreateBlankZip ZipfileName.zip
-----------------------------------------
Set Ag=Wscript.Arguments
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile(Ag(0), 8, vbtrue)
BlankZip = "PK" & Chr(5) & Chr(6)
For x = 0 to 17
BlankZip = BlankZip & Chr(0)
Next
ts.Write BlankZip

Unzip.vbs
Unzip can zip as well. Zips are folders for this purpose.
The messagebox statement is needed if destination is a zip (don't ask cos I dunno but it won't zip but will unzip if the message box statement doesn't exist). Folders MUST exist. Must quote parameters if they contain a space.
Unzip SourceFolder DestinationFolder.zip
-----------------------------------------------------------------------
Set objShell = CreateObject("Shell.Application")
Set Ag=Wscript.Arguments
set WshShell = WScript.CreateObject("WScript.Shell")
Set DestFldr=objShell.NameSpace(Ag(1))
Set SrcFldr=objShell.NameSpace(Ag(0))
Set FldrItems=SrcFldr.Items
DestFldr.CopyHere FldrItems, &H214
Msgbox "Finished"
 
Thanks for the information. Can you give me a bit more guidance as to how
and where I would use this code? Is this a batch or VBA or how do I
implement this?

Thanks again.
 
It's vbs but will be substantially similar, maybe identical, code in VBA (that is Visual Basic in Microsoft Office's Programs). The two files are meant to be used by people as samples to make their own vbs scripts and for the desperate as commands in a batch file (I added cmd line parameters - it used to require hand editing the names in the file).
 
As a batch

CreateBlankZip c:\myzip.zip
Unzip c:\AFolder c:\myzip.zip

It does whole folders as written.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top