Excel VBA – ZIP Compress a file

I just got a need to compress a file through Excel VBA, here’s what I have found so far from Google.
You will need adding reference to Microsoft Scripting Runtime and Microsoft Shell Controls and Automation (by clicking menu Tools > Reference)

Option Explicit
Option Base 0

Private Declare Sub Sleep Lib “kernel32″ (ByVal dwMiliseconds As Long)

Public Sub MakeZip(zipPath As String, filePath As String)
MakeEmptyZip zipPath
AddFile zipPath, filePath
End Sub

Private Sub AddFile(zipPath As String, filePath As String)
Dim sh As Shell32.Shell, fdr As Shell32.Folder, cntItems As Integer ‘cnt = Count
Set sh = CreateObject(“Shell.Application”)
Set fdr = sh.Namespace(zipPath)
cntItems = fdr.Items.Count
fdr.CopyHere filePath, 4 + 16 + 1024
Sleep 1000
Loop Until cntItems < fdr.Items.Count
Set fdr = Nothing
Set sh = Nothing
End Sub

Private Sub MakeEmptyZip(zipPath As String)
Dim fso As Scripting.FileSystemObject
Set fso = CreateObject(“Scripting.FileSystemObject”)
If fso.FileExists(zipPath) Then
fso.DeleteFile zipPath
End If
fso.CreateTextFile(zipPath).Write “PK” & Chr(5) & Chr(6) & String(18, Chr(0))
Set fso = Nothing
End Sub

Private Sub cmdCompress_Click()
Dim sourcePath As String
Dim zippedPath As String

Dim sourceBaseName As String
Dim zippedBaseName As String

Dim sourceFullPath As String
Dim zippedFullPath As String

sourcePath = “C:\Users\Remo\Downloads\”
zippedPath = “C:\Users\Remo\Downloads\”

sourceBaseName = “DATA.MDB”
zippedBaseName = “DATA_Compressed.zip”

sourceFullPath = sourcePath + sourceBaseName
zippedFullPath = zippedPath + zippedBase

Call MakeZip(zippedFullPath, sourceFullPath)

MsgBox (“File ” + sourceBaseName + ” successfully compressed into ” + zippedBaseName)
End Sub



VirtualBox – Change Focus from Guest to Host and Vice Versa (Windows Host)

I use Windows 7 host with Ubuntu Server and Centos Minimal guest, sometimes when I move mouse cursor into virtualbox window it will disappear, even I’ve tried to move the mouse everywhere the cursor could not appear outside virtualbox window. I just found that pressing RIGHT CTRL key will bring the cursor back outside virtualbox window

Create Your First Android App in Windows 7

1. install nodejs
2. npm install -g phonegap
3. npm install -g cordova


1. install java sdk
2. set JAVA_HOME environment variable. eg: JAVA_HOME=C:\Program Files\Java\jdk1.8.0_05
3. add JAVA’s bin folder to PATH environment variable, eg: C:\Program Files\Java\jdk1.8.0_05\bin


1. copy to desired location, eg: C:\dev
2. set ANDROID_HOME environment variable, eg: ANDROID_HOME=C:\dev\adt-bundle\sdk
3. add ANDROID’s tools and platform-tools folder to the PATH environment variable, eg: %ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools


1. copy to  sdk/tools folder
2. set ANT_HOME environement variable, eg: ANT_HOME=C:\dev\adt-bundle\sdk\tools\ant
3. add ANT’s tools and bin folder to PATH environment variable, eg:  %PATH%\tools;%ANT_HOME%\bin



java -version
java version “1.8.0_05″
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)

ant -version
Apache Ant(TM) version 1.9.3 compiled on December 23 2013

cordova -version

phonegap -version

$ cordova create hello com.example.hello “HelloWorld”
$ cd hello
$ cordova platform add android
$ cordova build
$ cordova emulate android

deploy to the device (enable USB DEBUGGING first, the connect the device via USB)
$ cordova run android