polps Posted March 26, 2010 Share Posted March 26, 2010 Hello all, I want to search for a string (inside a excel sheet)using the method Cells.Find Looking the VBA code I found this: Cells.Find(What:="text", After:=ActiveCell, LookIn:=xlValues, LookAt:= _ xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False) _ .Activate How this code can to be traduced in AutoIT? Tanks Gianluca Link to comment Share on other sites More sharing options...
Tvern Posted March 26, 2010 Share Posted March 26, 2010 Something like: #include <Excel.au3> $sFilePath1 = @ScriptDir & "\Test1.xls" $oExcel = _ExcelBookOpen($sFilePath1) $oExcel.Cells.Find("text",Default, $xlValues, $xlPart, $xlByRows, $xlNext).Activate Link to comment Share on other sites More sharing options...
PsaltyDS Posted March 26, 2010 Share Posted March 26, 2010 (edited) Traduced: Humiliated or disgraced by malicious and false statements ??? ??? Assuming you meant "Translated", try: .Cells.Find('What:="text", After:=' & $ActiveCell & ', LookIn:=' & $xlValues & ', LookAt:=' & $xlPart & ', SearchOrder:=' & $xlByRows & ', SearchDirection:=' & $xlNext & ', MatchCase:=' & False).Activate You have to track down the values for the variables (like $xlValues) if they are not already declared in Excel.au3, but I think other examples of this have been posted. Edited March 26, 2010 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
polps Posted March 27, 2010 Author Share Posted March 27, 2010 Traduced: Humiliated or disgraced by malicious and false statements Traduced... I'm sorry for my poor english! Yes I meant Translated... Thanks to you, the following code seems to work, but still remains an odd behaviour. If the same string are written in more cells, the code jump directly on the last cell, so it find only the last occurence. This is strange; i want search for the next cell (that contains the string) after the active cell, not for the last cell! Any idea? Thanks a lot again. $oExcel = _ExcelBookOpen($ExcelFile) $oExcel.Range("A1").Activate $sFindWhat = "text" $oExcel.Cells.Find($sFindWhat, $oExcel.ActiveCell, $xlValue, $xlPart, $xlByRows, $xlNext, False).Activate MsgBox (0,"",$oExcel.ActiveCells.Address) Link to comment Share on other sites More sharing options...
PsaltyDS Posted March 27, 2010 Share Posted March 27, 2010 I'm pretty sure it's the "After:=ActiveCell" part, which doesn't work as expected. Don't have Excel here, so I can't test anything. Sorry. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Juvigy Posted March 29, 2010 Share Posted March 29, 2010 This is a small example from my scripts that shows how to simply use find: With $oExcel.ActiveSheet.Range ("A1:M200") $c = .Find ("Some text") EndWith Link to comment Share on other sites More sharing options...
Fulano Posted March 29, 2010 Share Posted March 29, 2010 Assuming you meant "Translated", try: .Cells.Find('What:="text", After:=' & $ActiveCell & ', LookIn:=' & $xlValues & ', LookAt:=' & $xlPart & ', SearchOrder:=' & $xlByRows & ', SearchDirection:=' & $xlNext & ', MatchCase:=' & False).Activate Thanks for this tip, I've been looking for ages for a way to pass stuff to VBA using the Key:=Value syntax. I've been using this, which is a pain to read:.Find("", Default, Default, $xlWhole) #fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now