0 Replies Latest reply on Sep 13, 2012 4:53 AM by Bill joy

    DoScript() problem

    Bill joy Level 1

      Hi All

       

      I want to execute my script using  application.doScript() method.

      First I create Application and Then call application.doScript() method but it give Message "No documents open".

       

      I put my script at Trusted location C:\\Documents and Settings\\Administrator\\My Documents\\Adobe Scripts\\NewSript.jsx

      Now I want to execute my script using below method but it not execute and return message "No documents open".

       

      #include "indesign.h"

      INDESIGN::_Application oApplication;   

      if(oApplication.CreateDispatch(L"InDesign.Application") ==0)  // it start Indesign Application

      {

              //     not start

      }

      CString ScriptPath =L"C:\\Documents and Settings\\Administrator\\My Documents\\Adobe Scripts\\NewSript.jsx";

      oApplication.DoScript(COleVariant(ScriptPath),long(1246973031),covOpti onal,long(1699967573),ScriptPath);

       

      It prompt message "No document open". While I double click on NewScript.jsx it run sucessfully.

      General syntex of  oApplication.DoScript() is

       

      http://jongware.mit.edu/idcsjs5.5/pc_Application.html#doScript


      any doScript (script: varies[, language: ScriptLanguage=ScriptLanguage.UNKNOWN][, withArguments: Array of any][, undoMode: UndoModes=UndoModes.SCRIPT_REQUEST][, undoName: string=Script])

      Executes the script in the specified language as a single transaction.

       

      I use long(1246973031) for The java script language.

      I do not understand where is problem.

      my NewSript.jsx file data is

       

      var myDocument = app.activeDocument;

      var myTextFrame = myDocument.pages.item(0).textFrames.add();

      myTextFrame.geometricBounds = ["6p", "25p", "30p", "30p"];

      myTextFrame.contents = "Adobe Indesign !"

       

       

      Thanks