Reply
Thu 27 Oct, 2011 09:59 pm
Good evening.
I'm trying to code a website that will read data from an Excel file (stored either locally or elsewhere) and input a row of data (searched based on a Drop-Down List) into a table on the web page itself. Every time I open the page (it's currently stored on my local drive, on a laptop running Windows 7) in IE8, though, I get the error "Automation Server Can't Create Object" and nothing happens. The Excel file doesn't get opened and the table is blank. Thing is, though, I tried opening the same web page on another computer with IE6 and Windows 2000, and the Script works perfectly there.
I've been searching for a solution to this for a week, and some people suggested elsewhere that it's a problem with IE8's security settings. I lowered them as far as they'll go and enabled Running the Script Not Marked As Safe for all possible zones, same result, the Script refuses to run with the "Automation Server Can't Create Object" error. Here's the applicable lines of code:
function loadData() {
// try {
var Excel, Book;
var a = document.getElementById("projectDrop");
Excel2 = new ActiveXObject("Excel.Application"); <--- This is where the error seems to register
Book2 = Excel2.Workbooks.Open("TestSheet.xls");
idTmr = window.setInterval("Cleanup();",1000);
var sheet2 = Book2.Worksheets("Sheet1");
var b = document.getElementById('tableDisplay').getElementsByTagName('tr');
Excel2.Visible = false;
var i=1;
while(sheet2.Cells(i,1).Value != null)
{
if (sheet2.Cells(i,1).Value == a.options[a.selectedIndex].text)
{
b[0].cells[0].innerHTML = sheet2.Cells(i,1).Value;
b[0].cells[1].innerHTML = sheet2.Cells(i,2).Value;
b[0].cells[2].innerHTML = sheet2.Cells(i,3).Value;
b[0].cells[3].innerHTML = sheet2.Cells(i,4).Value;
}
i++;
}
Excel2.Quit();
// }
// catch(e) {
// }
}
I'm completely stumped, everyone. Is it some obscure setting I'm forgetting to check in IE8, is my Java not fully updated, or what is it? Again, it works perfectly on my old Windows 2000 w/ IE6 computer, but not on a recent Windows 7 laptop with IE8. I'd appreciate any help.
Thank you.