Opening Excel 2007 with javascript

The code below has been working fine for years, but will not work with an excel 2007, xlsx, document. If I'm on a workstation with office 2003, I get a box saying cannot open document. If I'm on a workstation with office 2007, excel opens but the document does not load and the window with my script hangs up. Is there any reason for this? Does the code require modification? I've googled it, but unable to find an answer.

Thanks!  
<script language=javascript>
		var appExcel = new ActiveXObject("Excel.Application");
		appExcel.Visible = true;
		appExcel.Workbooks.Open("<%=url%>");
		javascript:self.close();
	</script>

Open in new window

jpt99aceAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David H.H.LeeCommented:
Hi jpt99ace,
Could be the excel reader not installed properly in the workstation based on different version? Try to get one at Microsoft site: http://www.microsoft.com/downloadS/details.aspx?familyid=1CD6ACF9-CE06-4E1C-8DCF-F33F669DBC3A&displaylang=en.
Lastly, what is the value return for "url" server variable inside the javascript? That could be permission settings issue for ActiveX object to run properly. Please provide further details for inspections.

0
jpt99aceAuthor Commented:
Hi x_com, thanks for respondnig.

First of all, I work at Bank of America, where the new office 2007 is being pushed to all workstations. I've tried this on a few different workstations and get the same result where excel starts up but the document doesn't load. I've included the code with the full url variable expanded out. The same exact code opening an excel 2003 xls doc works fine. It seems to be just stopping at the workbooks.open statement and getting stuck there. Is there any chance that the command has changed for the newer version? It also is not executing the self.close command as the script window is staying open.

Thanks!

	<html>
	<body>
	<script language=javascript>
		var appExcel = new ActiveXObject("Excel.Application");
		appExcel.Visible = true;
		appExcel.Workbooks.Open("http://crpsfoiis69.bankofamerica.com:3794/xlsreports/joes_test_default_format.xlsx");
		javascript:self.close();
	</script>
	</body>
	</html>

Open in new window

0
David H.H.LeeCommented:
Hi jpt99ace,
>>..where excel starts up but the document doesn't load
Does any error return?

>>It seems to be just stopping at the workbooks.open statement and getting stuck there. Is there any chance that the command has changed for the newer version?
Ok, try put in this way. Put (\) before out put slash mark(/).
eg:
appExcel.Workbooks.Open("http:\/\/crpsfoiis69.bankofamerica.com:3794\/xlsreports\/joes_test_default_format.xlsx");

>>..It also is not executing the self.close command as the script window is staying open.
Try this:
javascript:self.close();

Change to
window.opener=self;
  window.close();


               
0
jpt99aceAuthor Commented:
I've found the solution. I simply needed to add .xlsx to the mime type list in IIS. I guess without the specific mime type, it simply will not serve the document. I didn't need to change any code.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.