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,
Excel = new ActiveXObject("Excel.Application");
Excel.Visible = false;
document.write("value is " + a + "  ;  ;  ;  ;");
b = my_function()
}while(a!=null || b!=null);