focus problem

G

Guido Van der Elst

I am trying to code the following:
I open an Excel sheet with ActiveX from Inet Explorer 5+ with a form button.
I go to the Excel window and make a few changes.
Then I go back to the Explorer window and want to capture some cell
information from the Excel sheet.
But then I get an "ExcelApp is undefined" error.

Can someone give me some ideas on how to solve this?

here is the code:

<html>
<head>
<script language="JavaScript">

function openxlspage() {
ExcelApp = new ActiveXObject("Excel.Application");
ExcelApp.DisplayAlerts = false;
ExcelApp.Workbooks.Open("http://servername/path/mysheet.xls", 3, false);
ExcelApp.visible = true;
}

function getxlspagevalues() {
ExcelApp.Workbooks(1).SaveAs("C:\\TEST.XLS");
}
</script>
</head>
<body>
<form name="formName">
<input TYPE="submit" NAME="openXLSbutton" VALUE="Open XLS"
onclick="openxlspage();">
</form>
<form name="getdataForm">
<input TYPE="submit" NAME="getXLSbutton" VALUE="Get values"
onclick="getxlspagevalues();">
</form>
</body>
</html>
 
O

Orlando Magalhães Filho

Hi Guido Van der Elst,

On your code I couldn't see the ExcelApp defined as global variable. Try
insert Dim ExcelApp statement like this:

<html>
<head>
<script language="JavaScript">
Dim ExcelApp

function openxlspage() {
ExcelApp = new ActiveXObject("Excel.Application");
ExcelApp.DisplayAlerts = false;
'and so on

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top