Select by text attribute and apply a style

I have several long Pages documents, where the same formatting is used through out, but Paragraph styles have not been used.


Example: On every page, there is a heading in Bold, font size 24.

There is a subheading in Bold, font size 12. etc


Question 1:

Is there any way to batch select every element that uses a formating combination and then apply a paragraph style to it.


(E.g. Select all text that is bold, with font size of 24 and then apply the Heading 1 Paragraph style).


I am guessing I would probably have to use AppleScript. I was looking at the documentation and found that it is possible to select by font size, but it doesn't seem possible to apply Paragraph styles.


Question 2:

If applying Paragraph styles isn't possible, is it possible to select all instances of text that use a particular font size at once? Then I could select all the text and just apply the style from the inspector with one click.


Question 3:

If multiple selection isn't possible, then is it possible to select the next instance of text that uses a particular font size (e.g. Next instance from the text insertion point). I could then use the Apple script with Keyboard Maestro, which has the capability to apply styles. The Apple script would move through the document selecting the desired text and would pause long enough for Keyboard Maestro to apply the style before moving to the next text instance.


Thanks for any help that can be offered.

MacBook Pro Retina

Posted on Jul 18, 2019 5:57 AM

Reply

Similar questions

6 replies

Jul 19, 2019 2:24 AM in response to big_smile

Although you can certainly determine what words of body text are a specific font size, you won't be able to select them for further interactive action from the Pages interface, or apply a paragraph, or character style, because the AppleScript Dictionary support for Pages v8.1 does not support this behavior. In general, it is a small figment of the prior AppleScript Dictionary support found for Pages '09 v4.3.


From a productivity standpoint, you would be better off in Word or LibreOffice with their extended Find/Replace facilities that do support styles.

Jul 18, 2019 3:43 PM in response to big_smile

If you want a detailed answer you need to provide details of what you are talking about.


Principally what version of Pages on what version of macOS.


I am going to guess that you are talking about Pages 8.1 in a late version of macOS probably Mojave.


Q1 No. With an outside chance that an AppleScript might fix it


Q2 No.


Q3 Possibly


The reasons are that all versions of Pages 5 to 8 lack the features of Pages '09 that let you find text with a ceratin attribute and then apply either a Paragraph Style or Character Style to it. They also lack the ability to select non-contiguous text. To cap it off Apple has given them inadequate AppleScript support.


There is a long list of missing features that have meant that Pages 5 to 8, along with the companion Numbers and Keynote, have dragged down the iWork productivity suite for the last six years from a level of marked superiority to a sop for Mac users who did not want to either pay for or put up with MsOffice.


Your choices are to use Pages '09 which will soon become unusable in macOS Catalina unless Apple pulls a rabbit out of the hat, Put up with Pages 8.1 in the hope that Apple will fix all its shortcomings when Apple has dragged its heels for 6 year, or switch to something else.

Jul 19, 2019 3:35 AM in response to big_smile

Unless you tell AppleScript to change the font face, size, or color of a word in the Pages v8.1 document, you won't see any visual trace in the document that the AppleScript has run. Thus, you cannot get or set the current cursor location, or get/set a given page number. AppleScript is not an extension of the Find/Replace tool where you see the selections that match, and can interact with them.


From a user prompt, AppleScript can take in a word and attempt to match that word to a list of all words that may match a particular critieria (e.g. font-face, font-size, color). Then if it is a unique word, and you have the index of where that word was found in your list of all words, then you can tell AppleScript to do something that it is allowed to do — with the next adjacent word. This wouldn't be much fun to program, and the program would be slow. This is all theoretical.

Jul 18, 2019 10:55 PM in response to PeterBreis0807

Thanks for the help. Yes I am using Pages version 8.1 (6369) on MacOS 10.14.5.


Is this the correct forum to ask about Apple Script for Pages, or do I need to post in the Apple Script section. I think I can probably pull of question 3, I just need advice on how to select the next instance with Apple Script.

Question 2 might also be possible with Apple Script, so it would be great to find out.

Jul 19, 2019 3:10 AM in response to VikingOSX

@VikingOSX Via Apple Script, is it possible to select the next instance of a word that has a font size? If that it possible, the Keyboard Maestro can take care of the rest.


By next instance, I mean the Apple script will go to the next word that matches, (the next one from the current cursor)


For Word/LibreOffice: These documents are actually part of a big workflow which is based around Pages. If worse comes to worst, I will have to switch to Word/LibreOffice, but at this stage, I'd just like to see if Pages is viable, as it will save having to set up the workflow again.


Thank you so much for your help and advice.


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.

Select by text attribute and apply a style

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