[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
Re: excel method find in VB2010
Change that to
Code:
xl.Cells.Find("*", missing, Excel.XlFindLookIn.xlValues, missing, Excel.XlSearchOrder.xlByColumns, Excel.XlSearchDirection.xlPrevious)
Re: excel method find in VB2010
Quote:
Originally Posted by
danasegarane
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
Re: excel method find in VB2010
Did you add reference to Excel Object using Add Reference Dialog box ?
Re: excel method find in VB2010
Quote:
Originally Posted by
danasegarane
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?
Re: excel method find in VB2010
Use Imports Statement in the Top of the Page
Code:
Imports Microsoft.Office.Interop
Re: excel method find in VB2010
Quote:
Originally Posted by
danasegarane
Use Imports Statement in the Top of the Page
Code:
Imports Microsoft.Office.Interop
great dana :D 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
Re: excel method find in VB2010
Re: excel method find in VB2010
Quote:
Originally Posted by
danasegarane
hi gana, it does not work :(
Re: excel method find in VB2010
Quote:
Originally Posted by
giodepa
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. :wave:
gio