Skip to main content
Known Participant
December 5, 2023
Answered

addd object style to text

  • December 5, 2023
  • 3 replies
  • 244 views

hello everybody,

I have multiple page +500 and i want to change all leters like in image below ?
is it possible to find two letters ( \<\u\w+) and add  object style to this letters (not manualy) ?

the letters can be in a table or in individual text boxes

 

 

like this:

 

 

 

This topic has been closed for replies.
Correct answer Willi Adelberger

I disagree. Since several version it is possible to apply paragraph frames as part of the paragraph style to paragraphs. With a paragraph frame it is possible to accomplish this without an additional text frame or an object style. 

3 replies

Peter Kahrel
Community Expert
Community Expert
December 5, 2023

You're absolutely right, Willi. Old habits die hard. Rounded corners can be set as a paragraph-border attribute. So all you need to do, Nick, is define a paragraph style and apply it using a simple Find/Change query.

 

 

Known Participant
December 5, 2023

thank you very much!

I also tried the code script and it works fine

Peter Kahrel
Community Expert
Community Expert
December 5, 2023

You'll have to place a text frame in the cells, enable the rounded corners, and place the text in that text frame.

 

First, create an object style with all the required settings applied (rounded corners, stroke weight, height, and width). Call it 'framed', then use this script.

 

style = app.documents[0].objectStyles.item ('framed');
app.findGrepPreferences = null;
app.findGrepPreferences.findWhat = '^\\u\\w+$';

// Nothing selected: target document
// Insertion point in cell: target the table
// Otherwise do nothing
if (!app.selection.length) {
  found = app.documents[0].findGrep();
} else if (app.selection[0].parent instanceof Cell) {
  found = app.selection[0].parent.parent.findGrep();
} else {
  exit();
}
  
for (i = found.length-1; i >= 0; i--) {
  f = found[i].insertionPoints[0].textFrames.add();
  f.appliedObjectStyle = style;
  found[i].move (LocationOptions.AT_BEGINNING, f);
}
Willi Adelberger
Community Expert
Willi AdelbergerCommunity ExpertCorrect answer
Community Expert
December 5, 2023

I disagree. Since several version it is possible to apply paragraph frames as part of the paragraph style to paragraphs. With a paragraph frame it is possible to accomplish this without an additional text frame or an object style. 

Willi Adelberger
Community Expert
Community Expert
December 5, 2023

To text you can only apply Paragraph and Character Styles, never Object Styles. You can automate Character Styles in Paragraph Styles with GREP and Nested Styles and you can include Paragrph Styles in Object and Cell Styles.