try{
    var idsave = charIDToTypeID( "save" );
        var desc53 = new ActionDescriptor();
        var idAs = charIDToTypeID( "As  " );
            var desc54 = new ActionDescriptor();
            var idPGIT = charIDToTypeID( "PGIT" );
            var idPGIT = charIDToTypeID( "PGIT" );
            var idPGIN = charIDToTypeID( "PGIN" );
            desc54.putEnumerated( idPGIT, idPGIT, idPGIN );
            var idPNGf = charIDToTypeID( "PNGf" );
            var idPNGf = charIDToTypeID( "PNGf" );
            var idPGAd = charIDToTypeID( "PGAd" );
            desc54.putEnumerated( idPNGf, idPNGf, idPGAd );
            var idCmpr = charIDToTypeID( "Cmpr" );
            desc54.putInteger( idCmpr, 9 );
        var idPNGF = charIDToTypeID( "PNGF" );
        desc53.putObject( idAs, idPNGF, desc54 );
        var idIn = charIDToTypeID( "In  " );
        desc53.putPath( idIn, savePath() );
        var idDocI = charIDToTypeID( "DocI" );
        desc53.putInteger( idDocI, 195 );
        var idCpy = charIDToTypeID( "Cpy " );
        desc53.putBoolean( idCpy, true );
        var idLwCs = charIDToTypeID( "LwCs" );
        desc53.putBoolean( idLwCs, true );
        var idEmbP = charIDToTypeID( "EmbP" );
        desc53.putBoolean( idEmbP, false );
        var idsaveStage = stringIDToTypeID( "saveStage" );
        var idsaveStageType = stringIDToTypeID( "saveStageType" );
        var idsaveBegin = stringIDToTypeID( "saveBegin" );
        desc53.putEnumerated( idsaveStage, idsaveStageType, idsaveBegin );
    executeAction( idsave, desc53, DialogModes.ALL );

    // =======================================================
    var idsave = charIDToTypeID( "save" );
        var desc55 = new ActionDescriptor();
        var idAs = charIDToTypeID( "As  " );
            var desc56 = new ActionDescriptor();
            var idPGIT = charIDToTypeID( "PGIT" );
            var idPGIT = charIDToTypeID( "PGIT" );
            var idPGIN = charIDToTypeID( "PGIN" );
            desc56.putEnumerated( idPGIT, idPGIT, idPGIN );
            var idPNGf = charIDToTypeID( "PNGf" );
            var idPNGf = charIDToTypeID( "PNGf" );
            var idPGAd = charIDToTypeID( "PGAd" );
            desc56.putEnumerated( idPNGf, idPNGf, idPGAd );
            var idCmpr = charIDToTypeID( "Cmpr" );
            desc56.putInteger( idCmpr, 9 );
        var idPNGF = charIDToTypeID( "PNGF" );
        desc55.putObject( idAs, idPNGF, desc56 );
        var idIn = charIDToTypeID( "In  " );
        desc55.putPath( idIn, savePath() );
        var idDocI = charIDToTypeID( "DocI" );
        desc55.putInteger( idDocI, 195 );
        var idCpy = charIDToTypeID( "Cpy " );
        desc55.putBoolean( idCpy, true );
        var idLwCs = charIDToTypeID( "LwCs" );
        desc55.putBoolean( idLwCs, true );
        var idEmbP = charIDToTypeID( "EmbP" );
        desc55.putBoolean( idEmbP, false );
        var idsaveStage = stringIDToTypeID( "saveStage" );
        var idsaveStageType = stringIDToTypeID( "saveStageType" );
        var idsaveSucceeded = stringIDToTypeID( "saveSucceeded" );
        desc55.putEnumerated( idsaveStage, idsaveStageType, idsaveSucceeded );
    executeAction( idsave, desc55, DialogModes.NO );
          } catch(e){}



          
          
function savePath()
  {
    
  try{
      app.activeDocument.path;
      return app.activeDocument.path;
      }catch(e){return Folder.myDocuments}

  }          