There are lot of logical as well as syntax errors in the code you have provided. I have tried to correct those with minimum changes to your original code.
The below code should work,
function my_function(){
var Excel;
Excel = new ActiveXObject("Excel.Application");
Excel.Visible = false;
return Excel.Workbooks.Open("C:/desktop/TEST.xls").ActiveSheet.Cells(l,i).Value;
}
var i=1;
var l=1;
do
{
a=my_function()
if (a!=null)
{
document.write("value is " + a + "  ;  ;  ;  ;");
i++;
}
else
{
l++;
i=1;
document.write("<br />");
}
b = my_function()
}while(a!=null || b!=null);