What if you want to copy and paste using a GP Macro? You can easily do it, but there’s a little trick to it. Let’s learn how!
The requirement was to create a bunch of manual payments with the User ID of who entered the payment being entered into the comment field. While there are many ways to accomplish this task, the client determined that using a mail-merge macro would be the best way to go.
Since the user running the macro is not static, the User ID needed to be copied from the GP Welcome window. The relevant part of the recorded macro is shown below. The copy and paste lines are highlighted.
CommandExec dictionary 'default' form 'Command_System' command UserID
NewActiveWin dictionary 'default' form Login window Login
CommandExec form BuiLtin command cmdEditCopy
MoveTo field 'Cancel Button'
ClickHit field 'Cancel Button'
NewActiveWin dictionary 'default' form sheLL window sheLL
ActivateWindow dictionary 'default' form 'PM_Manual_Payments' window 'PM_Manual_Payments'
CommandExec form BuiLtin command cmdEditPaste
TypeTo field 'Transaction Description' , 'sa'
Instead of actually performing the standard copy and paste, the macro hard-coded what it copied and retains that value forever. That’s not what they want, they need the recorded User ID to change dynamically according to whomever is logged in.
The solution is simple. When you record your macro, choose ‘Select All’ from the Edit menu and then select ‘Copy’. Do the same when you go to paste and the macro will perform the copy and paste function correctly. Here’s what the new macro code looks like after the change:
CommandExec dictionary 'default' form 'Command_System' command UserID
NewActiveWin dictionary 'default' form Login window Login
CommandExec form BuiLtin command cmdEditSelectAll
CommandExec form BuiLtin command cmdEditCopy
MoveTo field 'Cancel Button'
ClickHit field 'Cancel Button'
NewActiveWin dictionary 'default' form sheLL window sheLL
ActivateWindow dictionary 'default' form 'PM_Manual_Payments' window 'PM_Manual_Payments'
MoveTo field 'User Defined 1'
CommandExec form BuiLtin command cmdEditSelectAll
CommandExec form BuiLtin command cmdEditPaste
MoveTo field 'User Defined 2'
Hopefully this little tip will help you record more dynamic macros.
Until next post!
Leslie
2 comments:
Again, Leslie saves the day!
Thank you for your kind words,
I'm so happy this was of value for you. If you have any other Macro questions, please send them my way!
Live the Dream!
Leslie
Post a Comment