3 Replies Latest reply on Apr 19, 2009 7:11 PM by frameexpert

    Calling VBScript code inside of JavaScript

    frameexpert Level 4

      Hello All,

       

      I have a chunk of VBScript that I am using inside of an InDesign JavaScript script. It works on my machine, but on another machine, the VBScript portion throws some errors. It there a Windows setting that is required to allow VBScript to run from JavaScript? The other machine is being used remotely, so I am having difficulties troubleshooting this. Here is the function containing the VBScript code. I am using CS4 on Windows XP.

       

      Rick Quatro

      585-659-8267

      rick at frameexpert dot com

       

      function GetPdfPageCount(oFile)
      {
      var sFile = oFile.fsName.replace(/\\/g, "\\\\");
      var aFile = [sFile]; // An array of arguments.
      if(File.fs == "Windows")
      {
        var sGetPdfPageCount = "Dim AcroApp, AVDoc, PDDoc, iPages\r";
        sGetPdfPageCount += "Set AcroApp = CreateObject(\"AcroExch.App\")\r";
        sGetPdfPageCount += "Set PDDoc = CreateObject(\"AcroExch.PDDoc\")\r";
        sGetPdfPageCount += "If PDDoc.Open(arguments(0)) Then\r";
        sGetPdfPageCount += "  iNumPages = PDDoc.GetNumPages()\r";
        sGetPdfPageCount += "  Set oInDesign = CreateObject(\"InDesign.Application\")\r";
        sGetPdfPageCount += "  oInDesign.ScriptArgs.SetValue \"ScriptArgumentA\", CStr(iNumPages)\r";
        sGetPdfPageCount += "  PDDoc.Close()\r";
        sGetPdfPageCount += "End If\r";
        sGetPdfPageCount += "Set AcroApp = Nothing\r";
        sGetPdfPageCount += "Set PDDoc = Nothing\r";
        app.doScript(sGetPdfPageCount, ScriptLanguage.visualBasic,aFile);
        return Number(app.scriptArgs.getValue("ScriptArgumentA"));
      }
      }