I'm probably doing something wrong that's really basic, but I am struggling and need help.
I'm copying numbers from a couple of Excel cells using the Sendkey ^c command. then, I'm using ClipPut to store the numbers into variables. I then want to add those together using the command AmtTotal=Amt1+Amt2
When I try this, Winbatch stops with the error "variable could not be converted to a valid number"
When I look in Winbatch Studio, I can see the numbers have @CRLF on the end of them, so the number 7.32 shows as 7.23@CRLF and the variable now shows as a String_Unicode
There are no line feeds in my spreadsheet. These are simple cells, formatted as numbers (I've also tried text, general, etc) with simple numbers in them.
What am I doing wrong?
Thanks
Keith
Without getting into a discussion of the wisdom of using key strokes to do something when better alternative may exist, the carriage-return and line-feed are placed in the clipboard by either Excel or the Windows clipboard service. You simply need to remove them:
nVar = StrReplace(nVar, @CRLF, '')
Why do you even need the clipboard. If your script has Excel opened, a simple amt = Application.Worksheetfunction.Sum(cell1,cell2,celln...) where Application is your Excel Object.
I don't think anyone said the OP needs to us the clipboard.
I'm sorry, I thought ClipGet was a clipboard function.
Swoosh.