473,320 Members | 1,865 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

vb.net webform on 2000 returns "Bad variable type" for Excel

Hi Everybody,

I have a vb.net webform where I create the Excel
application/workbook/worksheet. On Windows 2000 server for some reason, I
keep getting an error("Bad variable type") when trying to first set the value
to a cell. I don't have the problem on 2003 server or XP, and I'm wondering
if anyone knows of a get around on 2000?

Try
EApp = CreateObject("Excel.Application")
EWB = EApp.Workbooks.Add
ESh = EWB.Worksheets.Add
Add2Log("Creating Excel objects")
Catch ex As Exception
Response.Write("<br><br>Error Creating Excel. Message:" &
ex.Message.ToString)
Add2Log("Error: " & ex.Message.ToString)
Exit Sub
End Try

......

ESh.Cells(1, 2).value = "Total"

The error message has been puzzling me and I can't seem to see why it would
return that error. It does seem to be creating the Excel objects okay

Nov 19 '05 #1
2 1888
I can reproduce it with the followoing aspx file. It works fine for me under
2003, but just hangs in 2000 server.

<script language="VB" runat="server">

Sub Page_Load(Sender as Object, E as EventArgs)
Dim EApp As Object, EWB As Object, ESh As Object
Dim rowcount
Try
EApp = CreateObject("Excel.Application")
EWB = EApp.Workbooks.Add
ESh = EWB.Worksheets.Add
rowcount = 1
ESh.Cells(rowcount, 2).value = "Total"
lblMsg.Text = Esh.Cells(rowcount, 2).Value
Catch ex As Exception
Response.Write("<br><br>Error Creating Excel. Message:" &
ex.Message.ToString)
Exit Sub
Finally
EWB.Close()
Esh = Nothing
EWB = Nothing
EApp = Nothing
End Try

End Sub

</script>

<html>

<head><title>My First ASP.NET Page</title></head>

<body>
<form action="myaspnet.aspx" method="post" runat="server">
<h1><asp:label id="lblMsg" runat="server"/></h1>
<p>
</p>
</form>
</body>

</html>
"David Reynolds" wrote:
Hi Everybody,

I have a vb.net webform where I create the Excel
application/workbook/worksheet. On Windows 2000 server for some reason, I
keep getting an error("Bad variable type") when trying to first set the value
to a cell. I don't have the problem on 2003 server or XP, and I'm wondering
if anyone knows of a get around on 2000?

Try
EApp = CreateObject("Excel.Application")
EWB = EApp.Workbooks.Add
ESh = EWB.Worksheets.Add
Add2Log("Creating Excel objects")
Catch ex As Exception
Response.Write("<br><br>Error Creating Excel. Message:" &
ex.Message.ToString)
Add2Log("Error: " & ex.Message.ToString)
Exit Sub
End Try

......

ESh.Cells(1, 2).value = "Total"

The error message has been puzzling me and I can't seem to see why it would
return that error. It does seem to be creating the Excel objects okay

Nov 19 '05 #2
David,

I'm having exactly the same problem, only I'm trying to access the content
of a cell. Did you ever come up with a resolution?

Thanks,
Paul

"David Reynolds" wrote:
I can reproduce it with the followoing aspx file. It works fine for me under
2003, but just hangs in 2000 server.

<script language="VB" runat="server">

Sub Page_Load(Sender as Object, E as EventArgs)
Dim EApp As Object, EWB As Object, ESh As Object
Dim rowcount
Try
EApp = CreateObject("Excel.Application")
EWB = EApp.Workbooks.Add
ESh = EWB.Worksheets.Add
rowcount = 1
ESh.Cells(rowcount, 2).value = "Total"
lblMsg.Text = Esh.Cells(rowcount, 2).Value
Catch ex As Exception
Response.Write("<br><br>Error Creating Excel. Message:" &
ex.Message.ToString)
Exit Sub
Finally
EWB.Close()
Esh = Nothing
EWB = Nothing
EApp = Nothing
End Try

End Sub

</script>

<html>

<head><title>My First ASP.NET Page</title></head>

<body>
<form action="myaspnet.aspx" method="post" runat="server">
<h1><asp:label id="lblMsg" runat="server"/></h1>
<p>
</p>
</form>
</body>

</html>
"David Reynolds" wrote:
Hi Everybody,

I have a vb.net webform where I create the Excel
application/workbook/worksheet. On Windows 2000 server for some reason, I
keep getting an error("Bad variable type") when trying to first set the value
to a cell. I don't have the problem on 2003 server or XP, and I'm wondering
if anyone knows of a get around on 2000?

Try
EApp = CreateObject("Excel.Application")
EWB = EApp.Workbooks.Add
ESh = EWB.Worksheets.Add
Add2Log("Creating Excel objects")
Catch ex As Exception
Response.Write("<br><br>Error Creating Excel. Message:" &
ex.Message.ToString)
Add2Log("Error: " & ex.Message.ToString)
Exit Sub
End Try

......

ESh.Cells(1, 2).value = "Total"

The error message has been puzzling me and I can't seem to see why it would
return that error. It does seem to be creating the Excel objects okay

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jawahar Rajan | last post by:
All, I am using a few Input type of "Image" instead of a classic submit button in a form to achieve various tasks for example image1 - add user image2 - modify user image3 - delete user...
1
by: G Fernandes | last post by:
Hi, can someone tell me what the following words mean as per C/clc: 1) token 2) token sequence 3) scalar variable 4) vector
0
by: da20 | last post by:
Hi, I am using office xp, in my code i am referencing excel 10 library. When I am trying to open application i have following exception: "Old format or invalid type library". Please help. using...
5
by: Alfredo Magallón Arbizu | last post by:
Hi, I have an ASP.NET app that works perfectly in Windows Server 2003, but fails in Windows 2000. It fails when trying to read the data in an Excel Workbook (range.value)... The error is: ...
2
by: Lenonardo | last post by:
Hi. I'm writing a VB.Net application to update multiple Excel Worksheets. I'm using late binding (i.e. all variables are objects + use createobject) I develop the application on an XP...
4
by: octavio | last post by:
Hello members of the comp.lang.c newsgroup. Please I need you help on the following one. Compiling the simple code I'm getting this error message. Why ? Please what's the correct type of the fb...
5
by: rod.weir | last post by:
Hello, I have the following code to iterate through each view in a SQL Server and call the "sp_refreshview" command against it. It works great until it finds a view that is damaged, or otherwise...
4
by: JackBlack | last post by:
Hi, all! Need a little help tracking down a runtime error problem. I'm getting this error: "Unable to cast object of type 'myStruct' to type 'myStruct'... but the two types are identical! I...
11
by: gg9h0st | last post by:
i saw a code refactorying onload event listener window.onloadListeners=new Array(); window.addOnLoadListener=function(listener) { window.onloadListeners=listener; } why declare the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.