By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,874 Members | 1,028 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,874 IT Pros & Developers. It's quick & easy.

Locating Data in an Excel Spreadsheet

P: n/a
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.
Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Just found another good article for this issue:

257757 INFO: Considerations for Server-Side Automation of Office
http://support.microsoft.com/?id=257757

Luke

"Microsoft Security Announcement: Have you installed the patch for
Microsoft Security Bulletin MS03-026?? If not Microsoft strongly advises
you to review the information at the following link regarding Microsoft
Security Bulletin MS03-026
http://www.microsoft.com/security/se...s/ms03-026.asp and/or to
visit Windows Update at http://windowsupdate.microsoft.com to install the
patch. Running the SCAN program from the Windows Update site will help to
insure you are current with all security patches, not just MS03-026."

Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.