H
Hugh McLaughlin
Hello everyone and thanks for your help in advance. This
is somewhat of a continuation of a thread that I posted
about one week ago. the heart of the project requires
using ADO.Net to extract data from an Excel spreadseet
and display it in an ASP.Net page. Unfortuantely, the
format of the page changes somewhat from day to day. For
that reason, I have determined that using the Find method
in Excel is the best way to determine the starting cell
to extract. However, I am having problems with the
syntax to connect to the spreasheet to use the Find
method (I have the OLDDb part working fine once I
determine the proper cell). I tried the following:
Dim MyExcel As Excel.Application
Dim MyWorkbook As Excel.Workbook
Dim MySheet As Excel.Worksheet
Dim MyCell As Excel.Range
MyExcel = CType(CreateObject
("Excel.Application"), Excel.Application)
MyWorkbook = CType(MyExcel.Workbooks.Add,
Excel.Workbook)
MyWorkbook = MyExcel.Workbooks.Open
(Filename:="C:\IFRS1.xls", UpdateLinks:=False,
ReadOnly:=False)
MySheet = CType(MyWorkbook.Worksheets(1),
Excel.Worksheet)
MyCell = MySheet.Cells.Find("30 Year Fixed -
Program 100")
MyCell = MyCell.Offset(1)
MyCell = MySheet.Rows(MyCell.Row).Find
("Rate") 'This is the start of the data chart for this
type
Literal2.Text = "The starting cell is " &
MyCell.Text
The first line of code generated the error
message "Cannot create Active x"
I then tried:
Dim myExcel As Excel.Application
Dim myWorkBook As Excel.Workbook
Dim myCell As Excel.Range
Dim mySheet As Excel.Sheets
myExcel = CreateObject("ExcelApplication")
myWorkBook = myExcel.Workbooks.Open
(Filename:="C:\IFRS1.xls", UpdateLinks:=False,
ReadOnly:=False)
mySheet = myWorkBook.Worksheets(1)
But received the same error. I did make the reference to
the Excel object, so I am not sure what is causing this
error or how to get this working. Any help would be
greatly appreciated. Thanks.
is somewhat of a continuation of a thread that I posted
about one week ago. the heart of the project requires
using ADO.Net to extract data from an Excel spreadseet
and display it in an ASP.Net page. Unfortuantely, the
format of the page changes somewhat from day to day. For
that reason, I have determined that using the Find method
in Excel is the best way to determine the starting cell
to extract. However, I am having problems with the
syntax to connect to the spreasheet to use the Find
method (I have the OLDDb part working fine once I
determine the proper cell). I tried the following:
Dim MyExcel As Excel.Application
Dim MyWorkbook As Excel.Workbook
Dim MySheet As Excel.Worksheet
Dim MyCell As Excel.Range
MyExcel = CType(CreateObject
("Excel.Application"), Excel.Application)
MyWorkbook = CType(MyExcel.Workbooks.Add,
Excel.Workbook)
MyWorkbook = MyExcel.Workbooks.Open
(Filename:="C:\IFRS1.xls", UpdateLinks:=False,
ReadOnly:=False)
MySheet = CType(MyWorkbook.Worksheets(1),
Excel.Worksheet)
MyCell = MySheet.Cells.Find("30 Year Fixed -
Program 100")
MyCell = MyCell.Offset(1)
MyCell = MySheet.Rows(MyCell.Row).Find
("Rate") 'This is the start of the data chart for this
type
Literal2.Text = "The starting cell is " &
MyCell.Text
The first line of code generated the error
message "Cannot create Active x"
I then tried:
Dim myExcel As Excel.Application
Dim myWorkBook As Excel.Workbook
Dim myCell As Excel.Range
Dim mySheet As Excel.Sheets
myExcel = CreateObject("ExcelApplication")
myWorkBook = myExcel.Workbooks.Open
(Filename:="C:\IFRS1.xls", UpdateLinks:=False,
ReadOnly:=False)
mySheet = myWorkBook.Worksheets(1)
But received the same error. I did make the reference to
the Excel object, so I am not sure what is causing this
error or how to get this working. Any help would be
greatly appreciated. Thanks.