@Robert at ID-Tasker Thanks. Here is the updated code :
//Get handle to a document
var myDoc = app.activeDocument;
//Get all paragraph styles in a document
var paraStyles = myDoc.paragraphStyles.everyItem();
//myDoc.allParagraphStyles [this is not working for some reason]
//Create a Dialog
var main_dialog = app.dialogs.add({name:"Convert Selected Paragraph Style to Outline"});
//Create a column and add to the main dialog
var dialog_column = main_dialog.dialogColumns.add();
//Create a row and add it to the main dialog
var dialog_rows = dialog_column.dialogRows.add();
//Add a static text and a dropdown in the row
dialog_rows.staticTexts.add({staticLabel:"Paragraph Styles",minWidth:100});
var dialog_ddl = dialog_rows.dropdowns.add({minWidth:100});
//Populate dropdown list with paragraph styles
dialog_ddl.stringList = paraStyles.name;
//Change the selected index to 1
dialog_ddl.selectedIndex=1;
//Show the dialog and save the result in a variable
resChoice = main_dialog.show();
//Save the selected choice in a vairable
dlgChoice = dialog_ddl.stringList[dialog_ddl.selectedIndex];
//Convert the selected choice to outline
var style = dlgChoice;
app.findGrepPreferences = null;
app.findGrepPreferences.appliedParagraphStyle = style;
list = app.activeDocument.findGrep();
if ( list.length < 0 )
{
alert( 'style ' + style.name + ' not found' );
app.findGrepPreferences = null;
}
else{
for(i=0;i<list.length;i++){
list[i].createOutlines();
}
}
app.findGrepPreferences = null;
Now one issue left. How do I remove the [No paragraph style] from the list.
This line is giving error:
paraStyles.shift();
Hi @Bedazzled532 , If the document happened to contain groups of styles, myDoc.paragraphStyles.everyItem() would not get all of the styles–it would skip styles inside of the groups.
You can use myDoc.allParagraphStyles, which returns an array (not a collection) of all the document paragraph styles. This uses the allParagrahStyles array and skips the first [No Paragraph Style]:
makeDialog();
var psSel;
function makeDialog(){
var theDialog = app.dialogs.add({name:"Dialog Components", canCancel:true});
with(theDialog){
with(dialogColumns.add()){
with(dialogColumns.add()){
staticTexts.add({staticLabel:"Paragraph Styles:"});
}
with(dialogColumns.add()){
psSel = dropdowns.add({stringList:getAllPStyles(app.activeDocument.allParagraphStyles), selectedIndex:0, minWidth:80});
}
}
if(theDialog.show() == true){
psSel = app.activeDocument.allParagraphStyles[psSel.selectedIndex+1];
main();
theDialog.destroy();
}
}
}
function main(){
alert("\rChosen Paragraph Style: " + psSel.name);
}
/**
* @ param the paragraph style array
* @ return array of names (skips [No Paragraph Style])
*/
function getAllPStyles(arr){
var a = new Array;
for(var i = 1; i < arr.length; i++){
a.push(arr[i].name);
}
return a
}

