Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export to Excel from ASP form

Status
Not open for further replies.

BEJW

Programmer
Mar 25, 2003
13
US
Hi All,

The following are my codes, but I got error:

"Export error '80010108'
The object invoked has disconnected from its clients.

Any suggestion?

Thanks.
JW







<HTML>
<HEAD><%@ LANGUAGE=&quot;VBSCRIPT&quot; %>
<TITLE>Excelface</TITLE>
</HEAD>
<BODY>

<%
dim whichAction
dim myconnection
dim rsPatientInfo
dim connectString
dim sqlString
dim requestPatientID

whichAction = Request.Form(&quot;Action&quot;)
response.write(whichAction)

' Create Object
Dim ExcelFace
Set ExcelFace = CreateObject(&quot;Excel.Sheet&quot;)
' show or dont show excel to user, TRUE or FALSE
ExcelFace.Application.Visible = True


connectString = &quot;Provider=Microsoft.Jet.OLEDB.4.0;&quot; _
& &quot;Data Source=C:\Inetpub\
set myConnection = Server.CreateObject(&quot;ADODB.Connection&quot;)

set rsPatientInfo = Server.CreateObject(&quot;ADODB.Recordset&quot;)



'Set ExcelFace = CreateObject(&quot;Excel.Sheet&quot;)
' show or dont show excelto user, TRUE or FALSE
ExcelFace.Application.Visible = True


connectString = &quot;Provider=Microsoft.Jet.OLEDB.4.0;&quot; _
& &quot;Data Source=C:\Inetpub\
set myConnection = Server.CreateObject(&quot;ADODB.Connection&quot;)

set rsPatientInfo = Server.CreateObject(&quot;ADODB.Recordset&quot;)
sqlString = &quot;select * from Patients, Examinations where Patients.PatientID = Examinations.ID&quot;
' open a connection
myConnection.Open connectString
' create a recordset
Set rsPatientInfo = myConnection.Execute(sqlString)

dim counter
counter = 0
with rsPatientInfo
do while not .EOF Or .BOF
ExcelFace.ActiveSheet.Range(&quot;F3:K25&quot;).Interior.ColorIndex = 6
' Create both the blue eyes
ExcelFace.ActiveSheet.Range(&quot;G6:G10&quot;).Interior.ColorIndex = 5
ExcelFace.ActiveSheet.Range(&quot;J6:J10&quot;).Interior.ColorIndex = 5
' Create a purple nose
ExcelFace.ActiveSheet.Range(&quot;H13:I18&quot;).Interior.ColorIndex = 29
' create a red mouth
ExcelFace.ActiveSheet.Range(&quot;G21:J24&quot;).Interior.ColorIndex = 3
' Write the text
ExcelFace.ActiveSheet.Cells(counter,1).Value = fields(0)
counter = counter + 1
.MoveNext
LOOP
end with

' Save the the excelsheet to excelface
dim fileName
fileName = inputbox (&quot;Enter File name&quot;, &quot;File Name&quot;)

ExcelFace.SaveAs fileName ' &quot;c:\excelface.xls&quot;
' Close Excel with the Quit method on the Application object.
ExcelFace.Application.Quit
' Release the object variable.
Set ExcelFace = Nothing
%>

The data is exported to file:
<a href=&quot;
<% response.write(fileName) %>
&quot;><% response.write(fileName) %>
' open a connection
myConnection.Open connectString
' create a recordset
Set rsPatientInfo = myConnection.Execute(sqlString)

dim counter
counter = 0
with rsPatientInfo
do while not .EOF Or .BOF
ExcelFace.ActiveSheet.Range(&quot;F3:K25&quot;).Interior.ColorIndex = 6
' Create both the blue eyes
ExcelFace.ActiveSheet.Range(&quot;G6:G10&quot;).Interior.ColorIndex = 5
ExcelFace.ActiveSheet.Range(&quot;J6:J10&quot;).Interior.ColorIndex = 5
' Create a purple nose
ExcelFace.ActiveSheet.Range(&quot;H13:I18&quot;).Interior.ColorIndex = 29
' create a red mouth
ExcelFace.ActiveSheet.Range(&quot;G21:J24&quot;).Interior.ColorIndex = 3
' Write the text
ExcelFace.ActiveSheet.Cells(counter,1).Value = fields(0)
counter = counter + 1
.MoveNext
LOOP
end with

' Save the the excelsheet to excelface
dim fileName
fileName = inputbox (&quot;Enter File name&quot;, &quot;File Name&quot;)

ExcelFace.SaveAs fileName ' &quot;c:\excelface.xls&quot;
' Close Excel with the Quit method on the Application object.
ExcelFace.Application.Quit
' Release the object variable.
Set ExcelFace = Nothing
%>

The data is exported to file:
<a href=&quot;
<% response.write(fileName) %>
&quot;><% response.write(fileName) %>
%>
</BODY>
</HTML>
 
this is a long shot, but should be
Set ExcelFace = Server.CreateObject(&quot;Excel.Sheet&quot;)

I have to admit I have never seen this error and there isn't much out there for reference to it but some crystal report version issues. I'll seach a bit longer and see but I think I'm at a loss.


____________________________________________________
$str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
$Nstr = ereg_replace(&quot;sleep&quot;,&quot;coffee&quot;,$str); echo $Nstr;

onpnt2.gif
 
onpnt

this is an off topic but I still want to ask ...

I've seen many questions were people create instances of various MsOffice objects such as Excel or Access ... this is seems really intresting to me ... it opens new horisonts :) where can I find more info on what objects I can create and their methods and properties ?

sorry again for off topic

Sergei


 
Hi, onpnt,

But I got another error when I changed to &quot; Set ExcelFace = Server.CreateObject(&quot;Excel.Sheet&quot;)&quot;.

The Error:Server object error 'ASP 0196 : 80040154'

Cannot launch out of process component

/post.asp, line 20

Only InProc server components should be used. If you want to use LocalServer components, you must set the AspAllowOutOfProcComponents metabase setting. Please consult the help file for important considerations.


Thanks again.
JW

 
afer checking I was incorrect in that.

still looking into this error though and I'm coming up short which is getting lightly irritable.

anyone else have some suggestions on the error. I've in assuming this is not the script and a IIS component problem. maybe I'm just searching in the wrong place.

____________________________________________________
$str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
$Nstr = ereg_replace(&quot;sleep&quot;,&quot;coffee&quot;,$str); echo $Nstr;

onpnt2.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top