In Search and replace change words to bold

Discuss AppleScripting for QuarkXPress 2015 & 2016.

In Search and replace change words to bold

Postby mark lane » 23 Mar 2016, 15:41

In the SearchAndReplace I need to change several words in a document into a bold typeface. Is there a way to do this using what I have here? You can change a lot in the find and change but I haven't found anything in the forums that show all the things you can do with it using applescript. I have the simple text change, but I need to change several words to bold (Item#, Blade:, Handle:, Other info:) all to Optima Bold. Thanks for any help!

tell application "QuarkXPress"
activate
my SearchAndReplace1("~", " ")
end tell
----------------------------
on SearchAndReplace1(search_item, replace_item)
tell documents of application "QuarkXPress"
try
with timeout of 60 * 60 seconds
set (every text of every story where it is search_item) to replace_item
end timeout
end try
end tell
end SearchAndReplace1
mark lane
 
Posts: 44
Joined: 27 Sep 2004, 14:16

Re: In Search and replace change words to bold

Postby Jean-Marie Schwartz » 24 Mar 2016, 06:19

Hi!

Try this, provided you have a character style called "bold":
Code: Select all
tell application "QuarkXPress9"
   activate
   my SearchAndReplace1("start", "end")
end tell
----------------------------
on SearchAndReplace1(search_item, replace_item)
   tell documents of application "QuarkXPress9"
      try
         with timeout of 60 * 60 seconds
            set (character style of every text of every story where it is search_item) to "bold"
            set (every text of every story where it is search_item) to replace_item
         end timeout
      end try
   end tell
end SearchAndReplace1
Jean-Marie Schwartz

= Mac Pro Quad-Core Intel 2.8 GHz • 10 Go 1066 MHz DDR3 • Mac OS 10.10.4 • QuarkXPress 9.5.4.1 • Adobe CS5 =
Jean-Marie Schwartz
 
Posts: 2483
Joined: 23 Nov 2004, 04:30

Re: In Search and replace change words to bold

Postby mark lane » 24 Mar 2016, 13:27

Weirdness going on here. I've got your script to work fine when there is no embedded picture boxes. If I have a embeded picture box it will do one of two things:
| G-10; Other Info: Black =before script

If I leave both lines of code in it makes bold what it should but it take out surrounding text.
set (font of every text of every story where it is search_item) to "B Optima Bold"
set (every text of every story where it is search_item) to replace_item
| G-10Other Info:o: Black =after script


If I leave just1 line of code in it, it only makes ; Other Inf bold. so a semi colon a part of a word.
set (font of every text of every story where it is search_item) to "B Optima Bold"
Black | G-10; Other Info: Black

A little more background. I'll have a few pages of three columns filled with embedded images and descriptions.
Is there another way to tackle this?
mark lane
 
Posts: 44
Joined: 27 Sep 2004, 14:16

Re: In Search and replace change words to bold

Postby mark lane » 25 Mar 2016, 11:31

So, I got this to work.
try
with timeout of 60 * 60 seconds
set (every text where it is "~") to " "
set (every text where it is "^") to (return)
end timeout
end try
try
set (font of every text where it is "Handle:") to "B Optima Bold"
set (font of every text where it is "Other info:") to "B Optima Bold"
set (font of every text where it is "Sale!") to "B Optima Bold"
end try
mark lane
 
Posts: 44
Joined: 27 Sep 2004, 14:16

Re: In Search and replace change words to bold

Postby Jean-Marie Schwartz » 29 Mar 2016, 03:00

Hi! Sorry it didn't work as expected on your end. Didn't imagine such weirdness because of pictures.
Glad you have found a workaround in the meantime. Enjoy!
Jean-Marie Schwartz

= Mac Pro Quad-Core Intel 2.8 GHz • 10 Go 1066 MHz DDR3 • Mac OS 10.10.4 • QuarkXPress 9.5.4.1 • Adobe CS5 =
Jean-Marie Schwartz
 
Posts: 2483
Joined: 23 Nov 2004, 04:30


Return to QuarkXPress 2015/2016: Scripting

Who is online

Users browsing this forum: No registered users and 1 guest