473,545 Members | 2,797 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("E xcel.Applicatio n")
EWB = EApp.Workbooks. Add
ESh = EWB.Worksheets. Add
Add2Log("Creati ng Excel objects")
Catch ex As Exception
Response.Write( "<br><br>Er ror Creating Excel. Message:" &
ex.Message.ToSt ring)
Add2Log("Error: " & ex.Message.ToSt ring)
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 1906
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(Sende r as Object, E as EventArgs)
Dim EApp As Object, EWB As Object, ESh As Object
Dim rowcount
Try
EApp = CreateObject("E xcel.Applicatio n")
EWB = EApp.Workbooks. Add
ESh = EWB.Worksheets. Add
rowcount = 1
ESh.Cells(rowco unt, 2).value = "Total"
lblMsg.Text = Esh.Cells(rowco unt, 2).Value
Catch ex As Exception
Response.Write( "<br><br>Er ror Creating Excel. Message:" &
ex.Message.ToSt ring)
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="myaspne t.aspx" method="post" runat="server">
<h1><asp:labe l 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("E xcel.Applicatio n")
EWB = EApp.Workbooks. Add
ESh = EWB.Worksheets. Add
Add2Log("Creati ng Excel objects")
Catch ex As Exception
Response.Write( "<br><br>Er ror Creating Excel. Message:" &
ex.Message.ToSt ring)
Add2Log("Error: " & ex.Message.ToSt ring)
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(Sende r as Object, E as EventArgs)
Dim EApp As Object, EWB As Object, ESh As Object
Dim rowcount
Try
EApp = CreateObject("E xcel.Applicatio n")
EWB = EApp.Workbooks. Add
ESh = EWB.Worksheets. Add
rowcount = 1
ESh.Cells(rowco unt, 2).value = "Total"
lblMsg.Text = Esh.Cells(rowco unt, 2).Value
Catch ex As Exception
Response.Write( "<br><br>Er ror Creating Excel. Message:" &
ex.Message.ToSt ring)
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="myaspne t.aspx" method="post" runat="server">
<h1><asp:labe l 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("E xcel.Applicatio n")
EWB = EApp.Workbooks. Add
ESh = EWB.Worksheets. Add
Add2Log("Creati ng Excel objects")
Catch ex As Exception
Response.Write( "<br><br>Er ror Creating Excel. Message:" &
ex.Message.ToSt ring)
Add2Log("Error: " & ex.Message.ToSt ring)
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
18769
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 image4 - reSet user.
1
2348
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
1312
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 Excel = Microsoft.Office.Interop.Excel; / / / /
5
3944
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: COMException (0x80020008): Bad Variable Type
2
7639
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 machine with Excel 2002 (version 10.0) installed - and the code works fine. I then test the code on a laptop running Excel 2000 (version 9.0) and it
4
11337
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 function ? Thank You. Octavio and.c:15: attention : type mismatch with previous implicit declaration and.c:11: attention : previous implicit...
5
2662
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 cannot be refreshed. Then the whole routine stops working. Can someone please help me re-write this code so that any views that fail the...
4
2449
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 have a class method that's building an array of user-defined structures (see below), and returning that array to the calling routine. I'm getting...
11
2205
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 onloadListeners, addOnLoadListener below window?
0
7692
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
6026
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5360
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5078
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3491
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3470
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1921
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1045
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
744
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.