Copy link to clipboard
Copied
I'm running CS 5.5. Can anyone tell me if there is a way to "gather" or "export" all text that is styled with one particular style into a separate document? Or delete all text except this style?
Copy link to clipboard
Copied
I've moved this into the scripting forum where I think you'll find more help...
Copy link to clipboard
Copied
You can use a script (ExtendScript/JavaScript) like this:
app.changeTextPreferences = app.findTextPreferences = null;
//Insert the name of your character style here:
app.findTextPreferences.appliedCharacterStyle = "NameOfCharacterStyleHere";
var _textFoundArray = app.activeDocument.findText(true);
//All found texts will be copied to a new text frame on page 1 of your document separated in paragraphs of their own:
var _targetTextFrame = app.activeDocument.textFrames.add({
geometricBounds:[0,0,100,100]
});
for(var n=0;n<_textFoundArray.length;n++){
_textFoundArray
.duplicate(LocationOptions.AFTER, _targetTextFrame.insertionPoints[0]); _targetTextFrame.insertionPoints[0].contents = "\r";
};
_targetTextFrame.characters[0].remove();
app.changeTextPreferences = app.findTextPreferences = null;
Just change NameOfCharacterStyleHere to the real name of your character style and run the script from the scripts panel. Your document should be open and "active".
Please, test this on a duplicate of your doc!
You will find all your found texts gathered in a new text frame on page one separated in paragraphs of their own. It's very likely that this text frame overflows after running the script.
Uwe
Copy link to clipboard
Copied
Thank you so much. Just a ittle more help please. This is a paragraph style not a character style so i changed the text "appliedCharacterStyle" to "appliedParagraphStyle", then put in the name of the paragraph style, however, it doesn't work. Is there something else i should do?
Copy link to clipboard
Copied
In what way does it not work? Is the text frame added on page 1, but does not contain text, or is there an error message?
Make sure you spell the paragraph style exactly right, with the correct capitalization.
Copy link to clipboard
Copied
The script should work as well. Did you put the name of your paragraph style between quotation marks?
Did a error message pop up?
Uwe
Copy link to clipboard
Copied
The name of the paragraph style is "D-Question".
yes, i put it between quotes.
I didn't get a message, it just gave me that "reject" sound.
Copy link to clipboard
Copied
I mentioned in the other forum (answer by email, before Peter moved it
here, so it might have got lost):
Why not just (1) change the font colour of the paragraph style you wish
to keep, say to red; (2) find all black text in the document and delete
it (presuming you only use black text in your document -- if not, use
another property you don't use, such as strikethrough, rather than font
colour); (3) the remaining text will be what you want to keep - just
change the style colour back to black.
Ariel
Copy link to clipboard
Copied
@Faith-Action
I sent you a private message with my e-mail address via the forum software.
To reproduce the problem it would be best to look into your document.
If you are interrested you could send me one single page exported as IDML file for testing.
Uwe
Copy link to clipboard
Copied
Thank you for sending me the test files. I looked into it, tested my script on it and all went fine…
So I really don't know what's going wrong on your end. You'll get my results by e-mail.
Annotation: since you work in inches just let's make the new text frame with the gathered texts way smaller.
Just change the following line from:
geometricBounds:[0,0,100,100]
to, let's say:
geometricBounds:[0,0,10,5]
But it should work either way. Also tested that with InDesign CS5.5 v7.5.1 (german).
Uwe
Copy link to clipboard
Copied
It seems my reply to the questions about the way the script worked didn't post so I'm trying that again.
Yes, it put the style name between the quotes: "D-Question"
I didn't get any sort of error message, nor the text frame, it just gave me that "reject" sound (don't know how to describe it).
Copy link to clipboard
Copied
You could change the style definition to colour all the text of the
style you want to keep red.
Then, presuming all the rest of the text is coloured black, you could
search for all black text and delete it, leaving only the red.
Then change the style back to black.
Ariel
Copy link to clipboard
Copied
That's a very interesting way to go about it. It would have worked except that most of the questions are in text boxes. The style change, of course, did change them to red, but when i did the search/replace for black text, it deleted all of those in text boxes along with the other styled text. Any suggestions?
Copy link to clipboard
Copied
Sorry, I'm not following. All text is in a text box in InDesign. If you
search for black text, I don't understand how it could have deleted red
text -- unless there is red text and black text in the same paragraph?
Copy link to clipboard
Copied
Yes, all text is in a text box but the questions are in the margins, in separate text boxes, which are anchored to a paragraph
Copy link to clipboard
Copied
I realized why the search/replace deleted the questions in boxes. They are anchored to other paragraphs.