mcguirepm
01-07-2005, 01:39 PM
I have a program that was originally written in VB5.0 that openned and manipulated several Excel spreadsheets. This worked tremendously well. :)
I have now imported this program into VB.Net and I am running into an error I can't seem to get around.
Dim MyFile as String
Dim AppExcel As Excel.Application
MyFile = Dir("T:\BOMS\masters\TS1500-140 Helix Curve Calc.*.xls")
AppExcel = CreateObject("Excel.Application")
AppExcel.Workbooks.Open(Filename:="T:\BOMS\masters\" & MyFile)
If AppExcel.Sheets("Frame Assembly 020950 Cut List".Range ("UpXMemMatl")) = "031503-49-38" Then
Do Something
Else
Do something Different
End If
.
.
.
I get the following error when I hit the IF statement:
An unhandled exception of type 'System.InvalidCastException' occurred in microsoft.visualbasic.dll
Additional information: Cast from type 'Range' to type 'String' is not valid.
Any insights would be appreciated.
Pat
I have now imported this program into VB.Net and I am running into an error I can't seem to get around.
Dim MyFile as String
Dim AppExcel As Excel.Application
MyFile = Dir("T:\BOMS\masters\TS1500-140 Helix Curve Calc.*.xls")
AppExcel = CreateObject("Excel.Application")
AppExcel.Workbooks.Open(Filename:="T:\BOMS\masters\" & MyFile)
If AppExcel.Sheets("Frame Assembly 020950 Cut List".Range ("UpXMemMatl")) = "031503-49-38" Then
Do Something
Else
Do something Different
End If
.
.
.
I get the following error when I hit the IF statement:
An unhandled exception of type 'System.InvalidCastException' occurred in microsoft.visualbasic.dll
Additional information: Cast from type 'Range' to type 'String' is not valid.
Any insights would be appreciated.
Pat