Wrox Programmer Forums
|
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 25th, 2005, 02:58 AM
Friend of Wrox
 
Join Date: May 2005
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Default excel create

Hi,
I use this code on my webserver on internet.
It is going to create an excel in c directory on local computer
bu when I run the code I get "object required error"
Does anyone have an idea?

on error resume next
intID=request.querystring("ID")
set fso = createobject("scripting.filesystemobject")
Set act = fso.CreateTextFile(("c:\" & strEventName & ".xls"), True)

set rs=server.createobject("adodb.recordset")
Rs.open "select * from GuestList where EventID=" & intID,Conn,3,3

act.WriteLine "<html xmlns:x=""urn:schemas-microsoft-com:office:excel"">"
act.WriteLine "<head>"
act.WriteLine "<!--[if gte mso 9]><xml>"
act.WriteLine "<x:ExcelWorkbook>"
act.WriteLine "<x:ExcelWorksheets>"
act.WriteLine "<x:ExcelWorksheet>"
act.WriteLine "<x:Name>"& strfilename &"</x:Name>"
act.WriteLine "<x:WorksheetOptions>"
act.WriteLine "<x:Print>"
act.WriteLine "<x:ValidPrinterInfo/>"
act.WriteLine "</x:Print>"
act.WriteLine "</x:WorksheetOptions>"
act.WriteLine "</x:ExcelWorksheet>"
act.WriteLine "</x:ExcelWorksheets>"
act.WriteLine "</x:ExcelWorkbook>"
act.WriteLine "</xml>"
act.WriteLine "<![endif]--> "
act.WriteLine "</head>"
act.WriteLine "<body>"
act.WriteLine "<table>"

act.WriteLine "<tr>"
act.WriteLine "<td>"
act.WriteLine "Email"
act.WriteLine "</td>"

act.WriteLine "<td>"
act.WriteLine "Attendance"
act.WriteLine "</td>"

act.WriteLine "<td>"
act.WriteLine "Comments"
act.WriteLine "</td>"

act.WriteLine "<td>"
act.WriteLine "Date_Replied"
act.WriteLine "</td>"

act.WriteLine "<td>"
act.WriteLine "# of Guests"
act.WriteLine "</td>"

act.WriteLine "<td>"
act.WriteLine "view Date"
act.WriteLine "</td>"


act.WriteLine "</tr>"

''''''''''''''''''''''''''''''''
do while not rs.eof
act.WriteLine "<tr>"

act.WriteLine "<td>"
act.WriteLine rs("Email")
act.WriteLine "</td>"


act.WriteLine "<td>"
act.WriteLine rs("attendance")
act.WriteLine "</td>"

act.WriteLine "<td>"
act.WriteLine rs("comment")
act.WriteLine "</td>"


act.WriteLine "<td>"
act.WriteLine rs("date_replied")
act.WriteLine "</td>"


act.WriteLine "<td>"
act.WriteLine rs("guest_brings")
act.WriteLine "</td>"

act.WriteLine "<td>"
act.WriteLine rs("viewDate")
act.WriteLine "</td>"

rs.moveNext
loop
act.WriteLine "</table>"
act.WriteLine "</body>"
act.WriteLine "</html>"
act.close



 
Old July 25th, 2005, 06:38 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 344
Thanks: 0
Thanked 1 Time in 1 Post
Default

The error is due to the Local Browser settings, check out http://www.greggriffiths.org/webdev/both/excel/ for some examples and a solution to this issue.
 
Old July 26th, 2005, 01:52 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

As this code is running on the server, and you are trying to create an Excel file in C:\<somewhere> on the server then either the server does not have the scripting.filesystemobject or more likely the account running ASP does not have rights to either create it or the file in the folder required. If you take off the "On Error Resume Next" and see what line the error is on it should be more helpful.


--

Joe (Microsoft MVP - XML)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Create excel file without Excel being installed NoXuS C# 4 August 29th, 2009 12:38 PM
Create excel file in vb monika.vasvani VB Databases Basics 0 July 17th, 2008 10:24 PM
Unable to create Excel object neha_jn Beginning VB 6 1 September 28th, 2004 10:06 AM
how to create a new series in excel charts pavankumar Excel VBA 0 November 7th, 2003 11:17 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.