• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1235
  • Last Modified:

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

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
Rika
Asked:
Rika
  • 4
1 Solution
 
markhoyCommented:
is Excel installed on the server? is the xls in that folder? Permissions on that folder allow IUSR_ to open it?
0
 
markhoyCommented:

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
 
RikaAuthor Commented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
markhoyCommented:
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
 
GaryCommented:
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now