L.S.
I found this great script to convert paragraphs (paragraph styles) to tables and apply a table style. It works great but I would like it to run for all the documents in my book. I normally use this ‘umbrella’ to run scripts for all documents in a book, but for some reason I can’t get it to work. Thanks in advance for any help.
book = app.activeBook;
for (var i=0; i<book.bookContents.length; i++)
{
var currentDoc = app.open (book.bookContents[i].fullName, false);
// DO THINGS HERE FOR EVERY BOOK
currentDoc.close(SaveOptions.YES);
}
Script to convert Paragraph to Table and apply table style
==================
app.findGrepPreferences = null;
app.findGrepPreferences.appliedParagraphStyle = app.documents.firstItem().paragraphStyles.itemByName( ‘PARAGRAPH STYLE NAME HERE’ );
var result = app.documents.firstItem().findGrep();
for (var i = result.length-1; i >= 0; i–)
{
var a_text =(result[i].characters.lastItem().contents == ‘\r’)
? result[i].parentStory.characters.itemByRange(result[i].characters.firstItem().index, result[i].characters.lastItem().index -1)
: result[i];
var a_table = a_text.convertToTable( );
}
app.findGrepPreferences = null;
var d = app.activeDocument;
var myTableStyle = myDisplayDialog ();
d.stories.everyItem().tables.everyItem().appliedTableStyle = myTableStyle;
d.stories.everyItem().tables.everyItem().clearTableStyleOverrides( true );
function myDisplayDialog(){
var myDialog = app.dialogs.add({name:”Choose a table style”});
with(myDialog.dialogColumns.add()){
var myTsDropDown = dropdowns.add({stringList: d.tableStyles.everyItem().name, selectedIndex:d.tableStyles.length-1});
}
var myResult = myDialog.show();
if(myResult == true){
var tS = d.tableStyles[myTsDropDown.selectedIndex];
myDialog.destroy();
}
else{
myDialog.destroy();
exit()
}
return tS;
}