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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DisplayContent Excel

Status
Not open for further replies.

mmetze

Programmer
Oct 2, 2001
45
US
i have a client who tries to execute the following code which displays data in an excel workbook within the browser. however, the result of executing this code is 'unable to initialize visual basic environment". i am unable to duplicate this problem locally on my box.

could this prob be related to: the browser, the OS, version of office? any help would be greatly appreciated!!!

<%
Sub Display()
On Error Resume Next

If Instr(1,sSQL,&quot;vRep&quot;) Then
sSQL = replace(sSQL,&quot;vRep&quot;,&quot;%'&quot;)
End If

set rs=server.CreateObject(&quot;ADODB.Recordset&quot;)
rs.Open sSQL,CON,3,2

Response.ContentType=&quot;application/vnd.ms-excel&quot;
%>
<table border=&quot;1&quot; align=&quot;center&quot; width=&quot;700&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;>
<tr>

<%
For each fld in rs.Fields%>
<td NOWRAP><%=fld.Name%></td>
<%Next
Response.Write &quot;</tr>&quot;

Do While rs.EOF=false
Response.Write &quot;<tr>&quot;
For each fld in rs.Fields
Response.Write &quot;<td>&quot; & fld.Value & &quot;</td>&quot;
Next
Response.Write &quot;</tr>&quot;
rs.MoveNext
loop
Response.Write &quot;</table>&quot;

If err.number <> 0 Then
Response.Write err.description
End If
End Sub
 
You may need to put this just after the
Response.ContentType=&quot;application/vnd.ms-excel&quot;


Response.AddHeader &quot;Content-Disposition&quot;, &quot;filename=mydata.xls;&quot;
 
by adding...

Response.AddHeader &quot;Content-Disposition&quot;, &quot;filename=mydata.xls;&quot;

... does this open an existing excel file within the browser? i am attempting to dynamically display data populated from a recordset into an excel workbook within the browser. i do not wish to open an existing file.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top