Mega Code Archive

 
Categories / VisualBasic Script / Windows API
 

Using VBA to Program Open XML Files

Sub UnzipPackage()          Dim o As Object          Dim TargetFile, NewFileName, DestinationFolder, ofile          TargetFile = ThisWorkbook.Path & "\SalesByPeriod.xlsx"          NewFileName = TargetFile & ".zip"          FileCopy TargetFile, NewFileName          DestinationFolder = "C:\MyUnzipped"               On Error Resume Next               MkDir (DestinationFolder)          Set o = CreateObject("Shell.Application")              For Each ofile In o.Namespace(NewFileName).items              o.Namespace(DestinationFolder).CopyHere (ofile)          Next ofile          Kill NewFileName          Set o = Nothing      End Sub