Unusual problem with Send> extra characters from Excel?

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
E Coli

Unusual problem with Send> extra characters from Excel?

Post by E Coli » Mon Feb 03, 2003 6:24 pm

Thanks to all who assisted me with my previous post. I believe I'm making some progress with my project. However, now I've come across another problem that has me stumped.

When I run the script below, the data pasted in notepad from Excel has extra carriage returns in it. What I expected to get in notepad would be:

Cell1Cell2Cell3Cell4

What I got was:

Cell1

Cell2

Cell3

Cell4

Does anyone know where the carriage returns came from? They were not in my Excel data, I ran the Clean function on them to remove any unprintable characters, but it didn't help. Has anyone seen this before? Thanks in advance for your help.

Eric
My Script is below

Let>row=1
Let>col=1

Label>startofloop
DDERequest>Excel,c:\SENDKEYS.xls,R%row%C%col%,xdata,2
If>row=4,exitloop

Setfocus>Untitled - Notepad
Send Character/Text>%xdata%
Add>row,1
Goto>startofloop

Label>exitloop
Message>done!

Lumumba

Post by Lumumba » Mon Feb 03, 2003 8:29 pm

//Divide the cell content with 1, this should remove the CRLF :idea:

Code: Select all

Let>xdata=%xdata%/1
or use (changes are bold)

Let>row=1
Let>col=1
Let>ydata=
...

Label>startofloop
DDERequest>Excel,c:\SENDKEYS.xls,R%row%C%col%,xdata,2
ConCat>ydata,%xdata%
If>row=4,exitloop,startofloop

Label>exitloop
Setfocus>Untitled - Notepad
Send Character/Text>%ydata%

Message>done!

E Coli

Post by E Coli » Mon Feb 03, 2003 8:59 pm

Thanks for the quick reply. However, I don't think I can divide the cell contents by 1, since the contents are a string. When I tried that the result I got was

Cell1/1

On the code below that, what does ydata do? I'm not sure what it is doing.

On a side note, I have found that there are two characters that are being added to the end of the cell content string. I am now looking at using a VB function to trim off the last two characters. Do you think that would work?

Thanks,
Eric

Lumumba

Post by Lumumba » Mon Feb 03, 2003 10:12 pm

Have you tried the sample code? Afterwards you would have realized that:

a) to the (previously empty) variable ydata, the content of xdata will be concatinated. With every loop ydata will "grow". The result: a single line with the content of all cells.

ydata=Cell1
ydata=Cell1Cell2
ydata=Cell1Cell2Cell3
ydata=Cell1Cell2Cell3Cell4

b) to get rid of 2 additional characters

Length>xdata,xlen
Sub>%xlen%,2
MidStr>%xdata%,1,%xlen%,xdata

E Coli

Post by E Coli » Tue Feb 04, 2003 11:00 am

Thanks for the explantion and the help. That seems to do just what I wanted.

Once again, thanks!

Eric

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts