How do I Find and Replace w Bold?

Pages 7.3 iMac 17,1 macOS 10.14.2


In a Pages document I want to FIND all instances of a word and REPLACE with it BOLD.

Does anyone know of a Find and Replace manual using OSX?

There are other things I want to do with Find and Replace.

iMac Line (2012 and Later)

Posted on Dec 17, 2018 1:09 PM

Reply
Question marked as Top-ranking reply

Posted on Dec 18, 2018 9:13 AM

The following AppleScript will prompt you for a search word, and then will bold it in that specific font wherever it is found in the body text of the document. Optionally, it will also set that word to a highlightColor if set, otherwise that will be ignored.


The original idea and script for this was originated by SGIII and I have modified it somewhat for this bold font specificity. Copy/paste into Script Editor, click compile, and run with an opened Pages document. You can also save this to the Desktop as a script, script bundle, or application.


set highlightColor to "blue"
set txtFormat to "Bold"
set matchCnt to (0 as integer)
set app_icon to "/Applications/Pages.app/Contents/Resources/AppIcon.icns"

use scripting additions

set searchWord to text returned of ¬
	(display dialog "Highlight what word?" default answer "" buttons {"Cancel", "Continue"} default button "Continue")

tell application "Pages"
	tell document 1's body text
		
		repeat with aword in (words where it is searchWord)
			
			tell application "Font Book"
				set ffnames to name of (font family (font of aword))'s typefaces
			end tell
			set font_name to (aword's font & space & txtFormat)
			if ffnames contains font_name then
				-- failure is tolerated if missing font_name or highlightColor
				try
					set aword's font to font_name
					set aword's color to highlightColor
				end try
				set matchCnt to matchCnt + 1
			end if
		end repeat
		
	end tell
end tell
display dialog "Find/Replace is complete." & return & return & "Search: " & searchWord & return & "Replacements: " & (matchCnt as text) buttons {"Done"} default button "Done" with title "Find/Replace Facility" with icon POSIX file app_icon as alias
return


Caveats:

  1. Not all fonts have "Name Bold" for bold font names, so script will not set any with hyphenated or abbreviated font names.
  2. Inspecting every word in the document to get a list of matches so it runs proportionately slower with larger documents.

Similar questions

12 replies
Question marked as Top-ranking reply

Dec 18, 2018 9:13 AM in response to blackxacto

The following AppleScript will prompt you for a search word, and then will bold it in that specific font wherever it is found in the body text of the document. Optionally, it will also set that word to a highlightColor if set, otherwise that will be ignored.


The original idea and script for this was originated by SGIII and I have modified it somewhat for this bold font specificity. Copy/paste into Script Editor, click compile, and run with an opened Pages document. You can also save this to the Desktop as a script, script bundle, or application.


set highlightColor to "blue"
set txtFormat to "Bold"
set matchCnt to (0 as integer)
set app_icon to "/Applications/Pages.app/Contents/Resources/AppIcon.icns"

use scripting additions

set searchWord to text returned of ¬
	(display dialog "Highlight what word?" default answer "" buttons {"Cancel", "Continue"} default button "Continue")

tell application "Pages"
	tell document 1's body text
		
		repeat with aword in (words where it is searchWord)
			
			tell application "Font Book"
				set ffnames to name of (font family (font of aword))'s typefaces
			end tell
			set font_name to (aword's font & space & txtFormat)
			if ffnames contains font_name then
				-- failure is tolerated if missing font_name or highlightColor
				try
					set aword's font to font_name
					set aword's color to highlightColor
				end try
				set matchCnt to matchCnt + 1
			end if
		end repeat
		
	end tell
end tell
display dialog "Find/Replace is complete." & return & return & "Search: " & searchWord & return & "Replacements: " & (matchCnt as text) buttons {"Done"} default button "Done" with title "Find/Replace Facility" with icon POSIX file app_icon as alias
return


Caveats:

  1. Not all fonts have "Name Bold" for bold font names, so script will not set any with hyphenated or abbreviated font names.
  2. Inspecting every word in the document to get a list of matches so it runs proportionately slower with larger documents.

Dec 17, 2018 11:42 PM in response to Barry

You know, I was always doubtful about using Product Feedback. Did it have any influence. But I used it to ask Apple to look at something in Pages this year. I had a problem when choosing a halftone or grayscale photo I had placed in Pages 7.3. I wanted to use the Pages editing tool to adjust the tone of my photos. This tool worked for several weeks, then all of a sudden quit working. I would adjust the tone, and closing the tool the photo would revert. I had deleted all files associated with Pages, and reinstalled. Opened and it did the same reversion. So I submitted Apple Product Feedback on the situation.


Do you know that Apple actually contacted me and wanted me to work w the Pages Team on resolving the issue.


The trouble in the mean time, I don't know how, I don't know if I had updated to 7.3, or what, but the issue disappeared. So I regrettably wrote back to Apple, I was sorry and happy, but the issue has resolved, and thanks for your attention.

Dec 18, 2018 1:47 AM in response to blackxacto

Do you know that Apple actually contacted me and wanted me to work w the Pages Team on resolving the issue.

The trouble in the mean time, I don't know how, I don't know if I had updated to 7.3, or what, but the issue disappeared. So I regrettably wrote back to Apple, I was sorry and happy, but the issue has resolved, and thanks for your attention.

Apple makes it pretty clear that they won't contact you unless it's to get more information on an issue you've reported on. That doesn't happen very often, but, as you've found out, there are cases in which it does happen.


Your input might have been key to that issue disappearing.


Regards,

Barry

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 Find and Replace w Bold?

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