Can't ClipGet from Spreadsheet and use data as an integer

Started by kmccarr, May 19, 2017, 08:30:21 AM

Previous topic - Next topic

kmccarr

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

td

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:

Code (winbatch) Select
nVar = StrReplace(nVar, @CRLF, '')   

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl

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.

td

I don't think anyone said the OP needs to us the clipboard. 
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl

I'm sorry, I thought ClipGet was a clipboard function.

td

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade