/    Sign up×
Community /Pin to ProfileBookmark

Need help with JScript problem in browser

Hi,

The following code, embedded in a web page’s HTML, works properly on a Windows 2000 computer with Excel 2000 and IE6, in which it opens an Excel file (in this case TestSheet.xls), dynamically populates a Drop-Down List in the web page itself (called projectDrop) based on entries in the first column of the sheet, and then searches and populates another table in the web page itself (called tableDisplay) using a row of data from the Excel sheet that matches the current selection in projectDrop. However, when I try to run this anywhere else — the first being a Windows 7 laptop with Excel Starter 2010 and IE8, and the second being a Windows XP laptop, also with Excel 2000 and IE8 — I get an ‘Automation server can’t create object’ error. This occurs even when I mark the web page as trusted, lower the security settings for ActiveX as far as they can possibly go, and even shut off my antivirus temporarily.

Both the HTML web page and the Excel sheet, TestSheet.xls, are currently stored and opened on the local hard drives.

Applicable code:

[code]
<script type=”text/javascript”>
function loadDropBox()
{
var x, Ex, Book;
x = document.getElementById(“projectDrop”);
Ex = new ActiveXObject(“Excel.Application”); <— Error occurs here
Book = Ex.Workbooks.Open(“TestSheet.xls”);
idTmr = window.setInterval(“Cleanup();”,1000);
var sheet = Book.Worksheets(“Sheet1”);
Ex.Visible = false;
var i=1;
var j=0;
while(sheet.Cells(i,1).Value != null)
{
x.options[j].value = j;
x.options[j].text = sheet.Cells(i,1).Value;
j++;
i++;
}
Ex.Quit();
}

function loadData() {
var Ex2, Book2;
var a = document.getElementById(“projectDrop”);
Ex2 = new ActiveXObject(“Excel.Application”); <— Error occurs here
Book2 = Ex2.Workbooks.Open(“TestSheet.xls”);
idTmr = window.setInterval(“Cleanup();”,1000);
var sheet2 = Book2.Worksheets(“Sheet1”);
var b = document.getElementByID(‘tableDisplay’).getElementsByTagName(‘tr’);
Ex2.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++;
}
Ex2.Quit();
}
[/code]

I’m starting to get desperate because searching on Google only gives a possible million things wrong with that particular error and that particular line, and I don’t know which is the true problem. Any help is highly appreciated.

to post a comment
JavaScript

1 Comments(s)

×

Success!

Help @JCHU12 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...