VS 2010 [RESOLVED] excel method find in VB2010-VBForums
Results 1 to 10 of 10

Thread: [RESOLVED] excel method find in VB2010

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2010
    Posts
    91

    Resolved [RESOLVED] excel method find in VB2010

    hi all,
    this is my first topic and I hope to do not some mistake.
    I decided to to convert my excel macro in a exe file using visual studio 2010.
    In excel macro method find is present like this:
    findRNC_row = xl.cells.Find(RNCid, SearchOrder:=xlByColumns, searchDirection:=xlNext).Row

    where xl is so defined:
    dim xl as object
    xl=createobject("excel.application")

    VB does not recognize SearchOrder:=xlByColumns and SearchDirection:=xlNext

    is it possible to use excel method find in vb2010?
    if yes, can someone help me please?

    thanks in advanced
    gio

  2. #2
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,833

    Re: excel method find in VB2010

    Change that to
    Code:
    xl.Cells.Find("*", missing, Excel.XlFindLookIn.xlValues, missing, Excel.XlSearchOrder.xlByColumns, Excel.XlSearchDirection.xlPrevious)
    Please mark you thread resolved using the Thread Tools as shown



    www.techreceipe.tk


  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2010
    Posts
    91

    Re: excel method find in VB2010

    Quote Originally Posted by danasegarane View Post
    Change that to
    Code:
    xl.Cells.Find("*", missing, Excel.XlFindLookIn.xlValues, missing, Excel.XlSearchOrder.xlByColumns, Excel.XlSearchDirection.xlPrevious)
    hi danasegarane,
    thanks for your reply.
    VB2010 does not recognize Excel object.
    How can I define it?

    BR,
    gio

  4. #4
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,833

    Re: excel method find in VB2010

    Did you add reference to Excel Object using Add Reference Dialog box ?
    Please mark you thread resolved using the Thread Tools as shown



    www.techreceipe.tk


  5. #5

    Thread Starter
    Lively Member
    Join Date
    Oct 2010
    Posts
    91

    Re: excel method find in VB2010

    Quote Originally Posted by danasegarane View Post
    Did you add reference to Excel Object using Add Reference Dialog box ?
    no I didn't.
    But now on project I selected "Add references"->"Browse" and then I selected Excel file.
    Is it correct?
    Even if in this way Vs2010 does not yet recognize it.

    EDIT
    if I insert Microsoft.Office.Interop.Excel , it works
    CAn I rename Microsoft.Office.Interop.Excel with Excel?
    Last edited by giodepa; Oct 25th, 2010 at 12:45 PM.

  6. #6
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,833

    Re: excel method find in VB2010

    Use Imports Statement in the Top of the Page

    Code:
    Imports Microsoft.Office.Interop
    Please mark you thread resolved using the Thread Tools as shown



    www.techreceipe.tk


  7. #7

    Thread Starter
    Lively Member
    Join Date
    Oct 2010
    Posts
    91

    Re: excel method find in VB2010

    Quote Originally Posted by danasegarane View Post
    Use Imports Statement in the Top of the Page

    Code:
    Imports Microsoft.Office.Interop
    great dana it works!!!
    Anyway "missing" is not recognized. Why?
    I have to write
    Code:
     xl.Cells.Find("*", missing, Excel.XlFindLookIn.xlValues,
    or
    Code:
     xl.Cells.Find("*", , Excel.XlFindLookIn.xlValues,
    thanks for your patience

  8. #8
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,833

    Re: excel method find in VB2010

    Try

    Code:
    Missing.Value
    Please mark you thread resolved using the Thread Tools as shown



    www.techreceipe.tk


  9. #9

    Thread Starter
    Lively Member
    Join Date
    Oct 2010
    Posts
    91

    Re: excel method find in VB2010

    Quote Originally Posted by danasegarane View Post
    Try

    Code:
    Missing.Value
    hi gana, it does not work

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Oct 2010
    Posts
    91

    Re: excel method find in VB2010

    Quote Originally Posted by giodepa View Post
    hi dana, it does not work
    Hi dana,
    I solved it.
    Correct syntax is:
    Code:
    xl.Cells.Find("*", , Excel.XlFindLookIn.xlValues, , Excel.XlSearchOrder.xlByColumns, Excel.XlSearchDirection.xlPrevious)
    Missing is not to be writed.

    gio

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.