472,121 Members | 1,508 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,121 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 1804
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Jawahar Rajan | last post: by
1 post views Thread by G Fernandes | last post: by
5 posts views Thread by Alfredo Magallón Arbizu | last post: by
11 posts views Thread by gg9h0st | last post: by

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.