Help with a VERY SIMPLE macro

Hi,

I started a super simple macro (at least I thought so), to copy two names into named clipboard. One clipboard is named Person and the other is called College. Then simple wanted to paste them. Nothing else. To try it, I created a simple spreadsheet, with only two words in each row. The macro supposed to copy the first cell into Person Clipboard, and the 2nd cell into the College Clipboard. Then, simply paste them. The macro however keeps pasting the same Clipboard into the two cells. I tried several variations, and re-created the macro from scratch several times. But no luck. Below is the macro and I'll try to upload a screen shot of the spreadsheet.

Hey Alex,

Firstly – it’s always a good idea to tell us what software (and version) you’re working with.

That looks like Excel – yes?

Excel implements a custom clipboard that can be quite vexing when trying to do copy and paste maneuvers.

Sometimes you can get around this by converting the clipboard to plain text.

In general you’re better off using variables than named clipboards, because variables are always plain text — clipboards can contain all kinds of stuff you’re unaware of.

(Of course for some kinds of data a named clipboard is the only way to go.)

For extracting data from a selection in Excel the best way is probably via AppleScript.

Select a couple of cells, and run this from Apple’s Script Editor.app:

----------------------------------------------
# Get values of selected cells.
----------------------------------------------
tell application "Microsoft Excel"
   # set mseSelection to value of selection
end tell
----------------------------------------------

Look in the result panel of the editor to see what comes of it.

Select a couple of blank cells, and run this from Apple’s Script Editor.app:

----------------------------------------------
# Set values of selected cells.
----------------------------------------------
set tempVar to {{"14:05:12:02", "14:06:07:21"}}

tell application "Microsoft Excel"
   set value of selection to tempVar
end tell
----------------------------------------------

You can do some quite sophisticated things with AppleScript in Excel…

-Chris

You don't really need Keyboard Maestro for this simple task.

First, why don't you just use an Excel formula:
D2: =B2
E2: =C2
and then copy down.

But if you really want a macro to copy, then it usually it is best to use Excel VBA when the entire workflow is within Excel.

Try this:

###Excel VBA Macro

Sub Set_Cell_Offsets()

    activeCell.Offset(0, 2) = activeCell
    activeCell.Offset(0, 3) = activeCell.Offset(0, 1)
    
End Sub

Thank you very much. I was only using Excel to test the various clipboards. My intention to read the variables from Excel (i.e. Name of the College, and the Program Coordinator – The two clipboard), then use PostBox (the Mac OS mail app) to send personalized applications.

I have started by using Variables (I’m rather new to KB), so I copied each cell to the clipboard, then from the clipboard to a variable. However, I ran to the same exact problem. So, I tried the Named Clipboard, but that didn’t help either.

Can you see a flaw in the script?

Alex

Hey Chris,

Yes, I should have listed my OS and the version. I’m using the latest Mac OS and a trial version of KM (version 7 - Downlaoded 2 days ago).

I started by trying to use the Variables (i.e. Copy to the Clipboard, then copy the clipboard to a variable A, move to the next cell, then repeat the same steps, but copy to Varible B). I ran to the very exact problem. When my search on YouTube showed that there is a “named clipboard”, I thought I’ll go that route. But as your answer suggests, maybe the issue is with Excel. Because when I open each variable, I find that it holds the correct name. It’s just when I paste it, that it pastes a something different.

Thank you very much,
Alex

OK, that makes a big different. In the future, please always give us the real-world, actual workflow you want to automate. That will get you a better, faster answer, and save us from wasting time. :wink:

I believe the problem is that Excel still has the first copy activated. So you need to cancel the Copy in Excel by using an ESC after the COPY Action:

This test Macro works for me. Please let us know if it works for you:

##Macro Library   @Excel Copy Paste @Test


####DOWNLOAD:
<a class="attachment" href="/uploads/default/original/2X/a/ab106fde7f882a6b8be30b60c48ca974cd0e3c17.kmmacros">@Excel Copy Paste @Test.kmmacros</a> (4.5 KB)

**Macro was uploaded in DISABLED state.  You must ENABLE before it will trigger.**

---

###ReleaseNotes

**HOW TO USE**

1. Select the first cell ("Name") in Excel
2. Trigger this macro

---

<img src="/uploads/default/original/2X/9/9a5ad58c41cbd91becd791b78d283dad86e8f8de.jpg" width="459" height="1263">

Hey There,
That worked out great!!! Thank you very much!!!
Alex