How to record caret position in Pages and go back to it?

I’m fairly n00b-ish at KM scripting beyond the basics. I want to be able to select some text in Pages, and have KM cut and paste the selected text into Pages’ Insert > Document Endnote, and have it return to where I was in the text. I can do the select, cut, paste, and insert the end note, but I can’t figure out how to return from the end of the doc to where I inserted the note. (You’d think Pages would link the end note numbers. You’d be mistaken.)

I have tried having KM insert a unique text string ("#HERE#") and then invoke Pages’ Find dialogue, find that string and delete, but it gets a bit fiddly.

I bet there’s a better way to do this…

Thanks!

Hey David,

Pages 5 scripting has gone to hell, so there's only so much you can do.

Fortunately Pages uses the normal system Find-Pasteboard, so you can do something like this:

-Chris

2 Likes

Works like a champ! Thanks so much, Chris.

David, glad to see that you got your macro working.

May I request that when you have your macro fully finished, and working well, that you publish it to the KM forum macro category?

This will help other users who have a similar need quickly find your macro.

See How to Post/Upload Your Macro to the Forum

Thanks.