Unable to paste from Excel

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Jaylee
Junior Coder
Posts: 45
Joined: Wed Feb 08, 2006 4:48 am

Unable to paste from Excel

Post by Jaylee » Wed Sep 12, 2007 7:49 am

Hi,

Using MS 9.0.046 on XP SP2 with Excel 2003.

I am using DDE Request to copy cell values from Excel to the clipboard and then pasting into destination fields in another application.

The problem I have is one specific destination field which simply will not accept pasted clipboard contents. I have had no problems with using DDE Request on other cells and pasting the results into the appropriate fields. I get the same issue with this field when performing the function manually. I can manually select cell D1 in Excel, CTRL+C, toggle to the destination field and then try to CTRL+V and get no result. However, If I access the "Insert function" field at the top of Excel after selecting the appropriate cell, select the value by swiping the mouse from right to left, then CTRL+C, I then have no problem pasting this into the destination.

Is there a way to access this area of Excel and highlight the entire value programmatically with MS, please?

I have searched this forum and tried using the "trim" functions as I thought there may be an issue with invisible characters and field maximums causing the problem but I still can't get a result.

I have also tried changing the format of the cells but with no joy.

I have tried substituting CTRL+V with GetClipBoard>%result% but this also doesn't work on this field.

Any other possibilities or suggestions would be gratefully received.

The code I am trying to use for this field is:

Code: Select all

SetFocus>Microsoft Excel - Extensions.xls
DDERequest>Excel,c:\Extensions.xls,R1C4,result,60
PutClipBoard>%result%
Wait>1
SetFocus>Copy Actions
Press TAB
Wait>1
Press CTRL
Send>v
Release CTRL
The same code with column changes works fine for other fields.

TIA.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Sep 12, 2007 10:11 am

Not quite sure I follow what you are trying to do. You are extracting a cell value from Excel with DDERequest and then trying to paste it somewhere else?

So, let's run through this bit by bit. First, what is the value of the data you are retrieving. Look at it in the debugger. Show it in a message box:

MessageModal>result

What is the length of it:

Length>result,lr
MessageModale%result% length:%lr%

Does it match up?

Perhaps there is a carriage return and/or line feed at the end?

StringReplace>result,CR,,result
StringReplace>result,LF,,result

Debug

Debug

..

Debug
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Wed Sep 12, 2007 12:43 pm

Have you tried simply sending the DDE captured text to the field?

Code: Select all

SetFocus>Microsoft Excel - Extensions.xls
DDERequest>Excel,c:\Extensions.xls,R1C4,result,60
Wait>1
SetFocus>Copy Actions
Press TAB
Wait>1

Send>%result%

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Wed Sep 12, 2007 1:25 pm

"The problem I have is one specific destination field which simply will not accept pasted clipboard contents. "

Will the destination field accept manually pasted data?

Update: JRL has kindly informed me you have already provided this information.

Next Question: If you can tell us, what exactly is the content of the cell you are trying to copy/paste?

Jaylee
Junior Coder
Posts: 45
Joined: Wed Feb 08, 2006 4:48 am

Post by Jaylee » Thu Sep 13, 2007 12:54 am

Thank you all for your responses.

I tried JRL's suggestion for Send>%result% and it worked! I had previously tried PutClipBoard>%result% with no joy and hadn't thought to try Send.

If anyone else is interested in answers to the other questions:
Yes, there is a line feed/carriage return at the end. I discovered this by pasting into Notepad and finding the cursor on the line below the pasted data. This was why I had tried to use a suggestion elsewhere on the forum for trimming invisible characters but I was not successful (probably my coding rather than the process). The frustrating part was that I'm doing exactly the same thing with other cells and pasting into other fields with no problems.

As for what I am copying/pasting, this cell always contains an 8 digit number and is pasted into a field which has an 8 digit limit.

Thank you to all for your comments and assistance, particularly JRL for his winning option!

:D :D :D

insider
Newbie
Posts: 1
Joined: Tue Mar 10, 2009 6:12 am

Post by insider » Tue Mar 10, 2009 6:21 am

Code: Select all

DDERequest>Excel,c:\Extensions.xls,R1C4,result,60
Wait>1
Please help. That is 60 in this string? Can i remove 60 on 0?
Wait>1 - is it necessary?

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