ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problems with the excel find function in vb.net (https://www.excelbanter.com/excel-programming/327018-problems-excel-find-function-vbulletin-net.html)

pp

Problems with the excel find function in vb.net
 
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

arunkhemlai

Problems with the excel find function in vb.net
 
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


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 doesnt recognise de following constants:
ActiveCell, xlFormulas, xlPart, xlByRows.

Do you have any ideas?

Thanks,
Paulo Praça



All times are GMT +1. The time now is 02:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com