Hi Chinnadk,
Please try this code also, may it will be helpful..
.Txt file generate in the document file path with the character style contents.
var myDoc = app.activeDocument;
contents = new Array;
app.findTextPreferences = app.changeTextPreferences = null;
app.findTextPreferences.appliedCharacterStyle = "aa"; //declared character style
var myFound = myDoc.findText();
for(k=0; k<myFound.length; k++)
{
contents.push(myFound[k].contents);
//~ alert(contents)
}
//To collect content in .txt format
var myFilePath = myDoc.filePath;
var myDocName = myDoc.name.split(".indd").join("_contents.txt");
var myTextFile = File(myFilePath+ "/" + myDocName);
myTextFile.open("w");
myTextFile.write(contents);
myTextFile.close();
If you need any more clarification please let me know.....
Thanks
Beginner