Sign in to follow this  
Followers 0
EasyGoing

If string

3 posts in this topic

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

Share this post


Link to post
Share on other sites



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)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by raggletaggle

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0