var idTmr = "";
function Cleanup() {
window.clearInterval(idTmr);
CollectGarbage();
}
function AutomateExcel()
{
var oXL = new ActiveXObject("Excel.Application");
oXL.DisplayAlerts = false
var oWB = oXL.Workbooks.Add();
var oSheet = oWB.ActiveSheet;
oXL.Visible = true;
oXL.UserControl = false;
oXL = null;
idTmr = window.setInterval("Cleanup();",1);
}