Copying Excel Data and Pasting in Another Program

General Macro Scheduler discussion

Moderators: Dorian (MJT support), JRL

Post Reply
BDB
Newbie
Posts: 5
Joined: Sun Jan 14, 2018 8:42 am

Copying Excel Data and Pasting in Another Program

Post by BDB » Sun Jan 14, 2018 10:17 am

Hello! I have an excel file that where data is coded based on where it is entered in the other program. For example, if excel file data has aa, the data is entered into field a in program x. I currently use a macro program the does a ctrl c in the description cell and when the code aa is detected in the clipboard, the macro triggers and copies the value in the next cell, moves to program x and pastes the value from excel into the appropriate field. It works but is glitchy because it relies on screen position of the field which often is not exact.

Does MacroScheduler have the ability to trigger when a certain value is detected in the clipboard? The image detection feature in Macro Scheduler has got my interest. Would it be possible to trigger a macro when aa is detected in the clipboard, set focus on program x, find an image of that field name description, center on image, move over from that position to get in the entry field, paste the value from excel and loop? Is there a more efficient way to accomplish this?

Thanks for the help!

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

Re: Copying Excel Data and Pasting in Another Program

Post by Marcus Tettmar » Mon Jan 15, 2018 5:33 pm

It is certainly possible to write code which would continually check the clipboard for a specific value and then act on it and do something else.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

BDB
Newbie
Posts: 5
Joined: Sun Jan 14, 2018 8:42 am

Re: Copying Excel Data and Pasting in Another Program

Post by BDB » Wed Jan 17, 2018 9:54 am

So far I really like the program! Much nicer than MacroExpress that I've been using for 10+ years! I've been playing around with it for several hours but can't figure out how to write an IF/Then statement that runs off the clipboard.

I would like to be in Excel (Temp.xlsx, sheet 1 and first data cell is in row 6 column 16

do a ctrl C
If clipboard value = aa* (*=wildcard), arrow right and copy, arrow down, arrow left
Else arrow down
and repeat the above until clipboard value is blank.

Thanks for the help.

BDB
Newbie
Posts: 5
Joined: Sun Jan 14, 2018 8:42 am

Re: Copying Excel Data and Pasting in Another Program

Post by BDB » Thu Jan 18, 2018 2:20 am

Well. I can't seem to get this program to work. Simple mouse movements, keyboard control and windows control are simple. I like the find image feature also. But this simple If/Then statement is getting the best of me. I can't seem to get any if/then stmt to work. Had no luck with Excel or clipboard functions either. I'm sure its simple once you figure it out but I'm about to give up.

The instructions are vague and I can't seem to find any useful examples. I really wanted to like this program but I just can't to make it work.

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

Re: Copying Excel Data and Pasting in Another Program

Post by Marcus Tettmar » Thu Jan 18, 2018 9:20 am

Sounds like you want to do something like this:

Code: Select all

//Send ctrl c
Press CTRL
Send>c
Releae CTRL
Wait>1
//get content of clipboard
GetClipBoard>value_in_clipboard
//does it start with "aa"
Pos>aa,value_in_clipboard,p,1
If>p=1
  //starts with "aa" so ..
  Press Right
  Wait>0.2
  Press CTRL
  Send>c
  Release CTRL
  Wait>0.2
  Press Down
  Press Left
Else
  Press Down
Endif
Of course without sitting in front of your screen I can't give you a definitive answer and the above is just an example based on what you have described. There are actually much better ways of getting info from Excel anyway.

​If you're struggling with the If/Then/Else basics then have a look at this:
http://help.mjtnet.com/article/9-making ... -and-endif
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

BDB
Newbie
Posts: 5
Joined: Sun Jan 14, 2018 8:42 am

Re: Copying Excel Data and Pasting in Another Program

Post by BDB » Thu Jan 18, 2018 10:14 am

Thanks Marcus! That really getting me started. I'll take a look at the if/then guide. I'm getting an Error in the Position Command though.

By the way, how would I change it up to do an exact match for aa ?

Thanks again.

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

Re: Copying Excel Data and Pasting in Another Program

Post by Marcus Tettmar » Thu Jan 18, 2018 4:25 pm

The error in the position command may be because the length of the string being checked is smaller than the thing you are looking for in it, (or it is empty). So before doing the Position thing make sure it's longer than 1 chars long (because "aa" is 2 chars long):

Code: Select all

Length>value_in_clipboard,lenV
If>lenV>1
  //code I sent you here
Endif
An exact match is way simpler:

Code: Select all

GetClipBoard>value_in_clipboard
If>value_in_clipboard=aa
  ...
Else
  ...
Endif
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

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