CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: ADO on Excel

  1. #1
    Join Date
    Aug 2001
    Location
    NY, USA
    Posts
    5

    ADO on Excel

    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.


  2. #2
    Join Date
    Aug 2001
    Posts
    5

    Re: ADO on Excel

    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



  3. #3
    Join Date
    Aug 2001
    Location
    NY, USA
    Posts
    5

    Re: ADO on Excel

    Thanks for your help.
    I just tried the find method and it seems like working fine.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured