EasyGoing Posted April 25, 2007 Share Posted April 25, 2007 I am coping a cell in excel and then valuating it in a IF statement. my code works if the value is numeric, but it errors if it is text. Can anyone hlep with this? Is it because the copy clipboard has triming issues? or what. inActivate("Microsoft Excel - question.xls") WinWaitActive("Microsoft Excel - question.xls") Send("^c") Sleep(100) $occupation = ClipGet() If $occupation = "test" Then Send("{DOWN}") Sleep(1000) Send("it works") ;send($occupation) Else Send("{DOWN}") Sleep(1000) Send("did not work") ;Send($occupation) EndIf Link to comment Share on other sites More sharing options...
Valuater Posted April 25, 2007 Share Posted April 25, 2007 this worked HotKeySet("{F9}", "Getit") While 1 Sleep(100) WEnd Func getit() WinActivate("Microsoft Excel - Book1") WinWaitActive("Microsoft Excel - Book1") Send("^c") Sleep(100) Local $occupation = StringReplace(ClipGet(), @CRLF, "") If $occupation = "test" Then Send("{DOWN}") Sleep(1000) Send("it works") ;send($occupation) Else Send("{DOWN}") Sleep(1000) Send("did not work") MsgBox(0,0, "*"&$occupation&"*") ;Send($occupation) EndIf EndFunc ;==>getit 8) Link to comment Share on other sites More sharing options...
raggletaggle Posted April 25, 2007 Share Posted April 25, 2007 (edited) You could also use excel COM if you don't want use as many sendkeys with the .value syntax $oExcel = ObjCreate("Excel.Application") $oExcel.Visible = 1 ; $oExcel.Workbooks.Open("path_to_your_excel_file") $value = $oExcel.ActiveWorkBook.ActiveSheet.Cells(1,1).Value $oExcel.ActiveWorkBook.Saved = 1 $oExcel.quit if $value = "test" then.... ... you get the idea. Edited April 25, 2007 by raggletaggle 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