Home All Groups Group Topic Archive Search About

Problems with the excel find function in vb.net

Author
7 Apr 2005 5:31 PM
pp
I have copied this code from Excel VBA, to use in a VB.net application:

Dim r as Excel.Range

r=Cells.Find(What:="02/01/2001  22:00:00", After:=ActiveCell,
LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)

But in VB.net, the editor doesn’t recognise de following constants:
ActiveCell, xlFormulas, xlPart, xlByRows.

Do you have any ideas?

Thanks,
Paulo Praça

Author
7 Apr 2005 6:49 PM
arunkhemlai
Imports Excel = Microsoft.Office.Interop.Excel

    Sub Main()
        Dim r As Excel.Range

        r = Cells.Find( _
            What:="02/01/2001  22:00:00", _
            , _  <-- Can leave it blank here
            LookIn:=Excel.XlFindLookIn.xlFormulas, _
            LookAt:=Excel.XlLookAt.xlPart, _
            SearchOrder:=Excel.XlSearchOrder.xlByRows, _
            SearchDirection:=Excel.XlSearchDirection.xlNext, _
            MatchCase:=False, _
            SearchFormat:=False)

            .....

More info -->
"http://msdn.microsoft.com/office/understanding/vsto/default.aspx?pull=/library/en-us/odc_vsto2003_ta/html/ExcelObj.asp"

HTH,
arunkhemlai


Show quoteHide quote
> I have copied this code from Excel VBA, to use in a VB.net application:
>
> Dim r as Excel.Range
>
> r=Cells.Find(What:="02/01/2001  22:00:00", After:=ActiveCell,
> LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows,
> SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
>
> But in VB.net, the editor doesn’t recognise de following constants:
> ActiveCell, xlFormulas, xlPart, xlByRows.
>
> Do you have any ideas?
>
> Thanks,
> Paulo Praça
>
Author
8 Apr 2005 4:48 PM
Paulo Praça
Many thanks for your answer. I had a problem with the first line of
code: Imports Excel = Microsoft.Office.Interop.Excel. I have this
answer: Namespace or type ‘Excel’ for the imports
‘Microsoft.Office.Interop.Excel’ cannot be found.

In the begin of my module I have these imports:
Imports Microsoft.Office.Core
Imports System.Data.OleDb

Thanks,
Paulo Praça


*** Sent via Developersdex http://www.developersdex.com ***