How do I modify a keyboard Maestro macro for Microsoft Word to work in Pages using AppleScript?

I am trying to modify a keyboard Maestro macro I use in Microsoft word to work in Pages. It goes through a document looking for certain variables and replacing with what I enter in a form. Here is how it is written for Word. It is an apple script.


tell application "System Events" to tell process "Word"


click menu item "Select All" of menu 1 of menu bar item "Edit" of menu bar 1


end tell




tell application "Microsoft Word"


set myFind to find object of selection


tell myFind


execute find find text "?Title" replace with theTitle replace replace all


execute find find text "?Series" replace with theSeries replace replace all


execute find find text "?sdat" replace with theDate replace replace all


end tell



-- replace footer as well


set findObject to (find object of text object of (get footer of section 1 of document 1 index header footer primary))


tell findObject


execute find find text "?Title" replace with theTitle replace replace all


end tell


end tell


I can't figure out how to get an auto selecting of the document in Pages. Any help or ideas appreciated.


macmikeal (at) Mac (dot) com


I tried to replace the menu 1 information with command an and it would take that.


[Re-Titled by Moderator]

Mac mini

Posted on Feb 11, 2025 11:35 AM

Reply

Similar questions

5 replies

Feb 12, 2025 05:46 AM in response to macmikeal

Your limiting factor with Pages is exactly that it is not a clone of Word and the Apple Script dictionary support for it is simply a shame.


All of your technology background and certifications won't save you from Apple's decision to gut the AppleScript dictionary support in Pages. None of our decades of technology career experience can change the limitations that Apple placed on Pages. Good luck.

Feb 11, 2025 12:47 PM in response to macmikeal

Pages is not a clone of Microsoft Word and neither share AppleScript Dictionary language. Word's AppleScript support is verbose and confusing, while Page's AppleScript support borders on minimal to useless.


Pages does not support document forms of any kind nor does the application support user-defined variables other than placeholder text. The latter is defined in a template and AppleScript can find placeholder tags in the document and replace them once. Without a form driving this as you have in MS Word, that may be difficult to script.


I have purposely stayed away from Word Apple scripting as it is too time-consuming to decipher and implement.


I don't use Keyboard Maestro either.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How do I modify a keyboard Maestro macro for Microsoft Word to work in Pages using AppleScript?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.