try{ if ( app.documents.length > 0 ) { // Make sure the is an open document var doc = activeDocument; // capture the document's name so... if ( doc.layers.length > 1){ // ...if there's more than one layer... var idslct = charIDToTypeID( "slct" ); // ...select the top-most layer var desc18 = new ActionDescriptor(); var idnull = charIDToTypeID( "null" ); var ref3 = new ActionReference(); var idLyr = charIDToTypeID( "Lyr " ); var idOrdn = charIDToTypeID( "Ordn" ); var idFrnt = charIDToTypeID( "Frnt" ); ref3.putEnumerated( idLyr, idOrdn, idFrnt ); desc18.putReference( idnull, ref3 ); var idMkVs = charIDToTypeID( "MkVs" ); desc18.putBoolean( idMkVs, false ); executeAction( idslct, desc18, DialogModes.NO ); } // ...Stamp Visible var idMrgV = charIDToTypeID( "MrgV" ); var desc14 = new ActionDescriptor(); var idDplc = charIDToTypeID( "Dplc" ); desc14.putBoolean( idDplc, true ); executeAction( idMrgV, desc14, DialogModes.NO ); } }catch(e){ //catch any errors }