Excel data handling

In excel when i am trying to compare cell value with predefined text , here i am getting error as mentioned below.
“Invalid type ‘TextVariant’ in comparison .”

Using Read_cell command the return type of ‘value’ is ‘General’. How can i convert this datatype to ‘text’ so that i can compare it with my own predefined text?

Try something like the code below. If you concatenate the “Value” that is the result of the Excel.ReadCell like this:


the error will disappear.


set myText to "I am some random text."

Excel.LaunchAndOpen                     Path:  "C:\Users\YourNameHere\Documents\Robin\tests\text1.xlsx"\
                                        Visible:True \
                                        Password:'' \
                                        ReadOnly:False \
                                        LoadAddInsAndMacros:False \
                                        Instance=> ExcelInstance

wait 1

Excel.ReadCell                          Instance: ExcelInstance \
                                        StartColumn:  "A" \
                                        StartRow:  1 \
                                        ReadAsText:True \
                                        Value=> Value

Console.Write Message: Value

if Value+"" = myText then
    Console.Write Message: "They are equal."
else if Value+"" != myText then
    Console.Write Message: "They are not equal."

Excel.Close Instance: ExcelInstance

Change either your variable or the text in the cell to verify.


1 Like

Thank you. Its working now.:slightly_smiling_face:

1 Like