Click to See Complete Forum and Search --> : ADO on Excel


shahp
August 27th, 2001, 03:48 PM
Hi,
I need to write a VB program to read Excel spreadsheet and transfer the info from the first tab of the spreadsheet to a Sybase table. The name of the first tab can be anything like 'Sheet1', or 'XYZ' or any thing ...different every time you run the program. On that sheet I need to find the word "ISSUER". Once the word is found I have to define the range from that word to currentregion and transfer the whole list into sybase table. What is the best way to do this.
I am thinking to define ADO on the Excel sheet but how do I find the sheet name. Should define Excel as a object. If any body has ever done something like this than please help.

Polkabora
August 28th, 2001, 11:05 AM
I don't know what you mean by region, but you can use the 'Find' Method of the 'Cells' object to find your word. It would be under the application object [Application].ActiveWorkbook.ActiveSheet.Cells.Find.You can then use the activecell object to get your current position and then you would define your range. You could then copy your data, paste into a new sheet which you could then reference through ADO(It appears you know how to do this through code). As for finding the current sheet name, the code is as follows:


Dim xlsApp As New Excel.Application
xlsApp.Workbooks.Add
'You can substitute your workbook name for 1 in WorkBooks.
MsgBox xlsApp.Workbooks(1).Worksheets(1).Name

shahp
August 28th, 2001, 02:06 PM
Thanks for your help.
I just tried the find method and it seems like working fine.