Skip to main content
Participant
January 4, 2011
Question

Selecting all colour/character style in document for index

  • January 4, 2011
  • 3 replies
  • 649 views

I have a problem, I am creating a directory and I need to build an index.

As you can see, I need to build an index with the text seen below in blue, but all I can do so far is manually do it by selecting the blue text and then adding it to a new entry into the index window.

http://www.insightgrp.co.uk/ForClients/Picture%203.png

Is there a script to help me do it all in one go?

Also I will need to do another index with just the Black Uppercase text  on another document later.

Thanks for you help in advance.

This topic has been closed for replies.

3 replies

Participant
January 7, 2011

Thanks for your help.

I have now done it but it wasn't as easy as I wished.

Cheers

Participant
January 4, 2011

Hi, thanks for that, but it comes up with an error.

http://www.insightgrp.co.uk/ForClients/Picture%204.png

tomaxxi
Inspiring
January 4, 2011

This error is not caused my script I sent you.

Did you copied scirpt to blank file?

--

tomaxxi

Participant
January 4, 2011

Have you entered your Character Style name?

--

tomaxxi


yes I have, some of them had a plus after the style, but I sorted that out. Is there a way to do it just by colour.

tomaxxi
Inspiring
January 4, 2011

Hey!

If your "blue" text is separate character or paragraph style, than this will do the job:

var myDoc = app.activeDocument;
if (myDoc.indexes.length == 0) myDoc.indexes.add();
var myIndex = myDoc.indexes.item(0);

app.findTextPreferences = NothingEnum.nothing;
app.changeTextPreferences = NothingEnum.nothing;
app.findTextPreferences.appliedCharacterStyle = "putHereYourCharacterStyleName";

// or

//app.findTextPreferences.appliedParagraphStyle = "putHereYourParagraphStyleName";

var myFind = myDoc.findText();

for(var i = 0; i < myFind.length; i++){
    myIndex.topics.add(myFind.contents);
}

Hope that helps.

--

tomaxxi

http://indisnip.wordpress.com/

http://inditip.wordpress.com/