?
Solved

Create a new ActiveX Excel Object to report data in VBSCRIPT / JAVASCRIPT

Posted on 2003-03-13
6
Medium Priority
?
1,202 Views
Last Modified: 2008-03-10
i have used the following code to open up an excel activexobject

Set xl = CreateObject("Excel.Application")

' Show Excel.
xl.Visible = True

' Open the file.
xl.Workbooks.Open "C:\test.xls"

the code however does not trigger or open up an Excel spreadsheet.

Kindly assist on how i would create a new excel object and represent my data in the cells.

thanking you
Rika
0
Comment
Question by:Rika
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
6 Comments
 
LVL 7

Expert Comment

by:markhoy
ID: 8128240
is Excel installed on the server? is the xls in that folder? Permissions on that folder allow IUSR_ to open it?
0
 
LVL 7

Expert Comment

by:markhoy
ID: 8128285

http://support.microsoft.com/support/kb/articles/Q257/7/57.ASP?LN=EN-US&SD=gn&FR=0&qry=OWC&rnk=13&src=DHCS_MSPSS_gn_SRCH&SPR=MSALL

http://support.microsoft.com/support/kb/articles/Q288/1/30.ASP?LN=EN-US&SD=gn&FR=0&qry=Excel%20Object&rnk=1&src=DHCS_MSPSS_gn_SRCH&SPR=ASP
 also,

It is not a question of the Extensions.. but rather one of having the registered code (the Excel Object Model DLL in this case) on the machine that you are doing the Excel file access. As you have Excel installed and registered on your machine.. all the necessary Excel program components are in place. As the Server does not have Excel installed, it does not have the necessary program code requirement.. and hence you receive the "ActiveX Cannot Be Found" error message.

To get the necessary Excel components to achieve what you want, Excel has to be installed on the Server. I know it suggz.. but Bill Gates didn't get to be a gazillionaire for doing nothing.. <sigh>.

If you can't install Excel on the Server, then you have one of two choices.

1) Lose the Excel spreadsheet and use another file type.. for data storage / retrieval.. (such as Microsoft Jet which is easily transportable.. and comes license free).

2) Have your ASP run an Out Of Process Component on a client machine that has Excel installed on it, to do all of your spreadsheet I/O. This is a much more complicated solution and let me add a much slower way to do this, but it will work if you want to put the energy into it.
0
 

Author Comment

by:Rika
ID: 8128472
Hi .. thanks for your efficient response.

firstly.. i need to create a New Excel Spreadsheet. It does not already exist.

i am not sure whether the server does have excel because i assumed that if the client had a copy of Excel it should execute of the accessing terminal.  Well u learn everyday. I'm a grad! I will look into it though and reply. :)

i tested it by popping a msgbox before the Excel open call and after the open call and the 2nd msgbox does not pop up after the
Set xl = server.CreateObject("Excel.Application")

any ideas?

thanks
Rika
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 7

Accepted Solution

by:
markhoy earned 200 total points
ID: 8128557
Dim ExcelObject
Set ExcelObject = GetObject(, "Excel.application")

If ExcelObject is Nothing then
Msgbox "Didn't work"
Else
ExcelObject.Quit  'close it
End If

Do you want to save your .xls file to the server or the client.  If you want to write an ASP page that will pull data from your Access database, you can display it in your browser window as and Excel spreadsheet.  This will only work if you have Excel installed on your client machine and if you are using IE.  All you need to do is add the following line to your code.  Here is some sample code that will create a no-frills excel report.

Response.ContentType = "application/vnd.ms-excel"
     for i = 0 to studentRS.Fields.Count -1
          sNames = sNames & (studentRS.Fields(i).Name & chr(9))
     next
     sNames = left(sNames, len(sNames) - 1)
     Response.Write(sNames) & vbcrlf
     do until studentRS.EOF
          for x = 0 to studentRS.Fields.Count - 1
               sRecord = sRecord & studentRS.Fields(x).Value & chr(9)
          next
          sRecord = left(sRecord, len(sRecord)-1)
          Response.Write(sRecord) & vbcrlf
          sRecord = ""
          studentRS.MoveNext
     loop
     
If you want to create this report on the server, I do not think it's possible to do without using a COM object and having Excel installed on the server.

http://www.experts-exchange.com/Web/Web_Languages/ASP/Q_20169222.html

0
 
LVL 58

Expert Comment

by:Gary
ID: 9350190
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept Answer by markhoy

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
GaryC123
EE Cleanup Volunteer
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question