6 Replies Latest reply on Dec 31, 2009 7:40 AM by MarkWalsh

    Applescript "do script" command


      I am having trouble with the do script command in applescript.  I am working with Acro Pro 8.


      This is the script...


      tell application "Adobe Acrobat Professional"

           tell active doc

                do script "this.getField(\"AE\").value"

           end tell

      end tell




      This is the error...


      Adobe Acrobat Professional got an error: "this.getField(\"AE\").value" doesn’t understand the do script message.


      I can get it to work by making it a file but I also need to pass a variable to Acrobat and would like to do it this way.

      Have any of you gotten this to work or have experience with the command.

        • 1. Re: Applescript "do script" command
          MarkWalsh Level 4

          That script works fine for me in Acrobat 7.0 (sorry, don't have version 8 on my home computer right now).


          But one thing I would suggest is to use single quotes in your javascript so that you don't have to escape the double quotes in Applescript. Don't know if that will solve the problem you are having in 8, but you could try it.


          do script "this.getField('AE').value"


          Edit: I do have version 8, and your code works fine for me in 8 as well. Are you sure there's a field named 'AE' in the document?

          • 2. Re: Applescript "do script" command
            mmrm Level 1

            I tried it with single quote and still did not work.  I put this.getField('AE').value into the javascript debugger and I get what I expect but I just can't get it to work in applescript.


            Note: I tried it with Acro Pro 7 but get "undefined" not the value. (osx 10.6.2)


            I also tried it in osx 10.4.11 with Acro Pro 7 and it did work.


            I really need it to work in osx 10.5 which with Acro Pro 7 gives me the same "undefined", no value, and errors with Acro Pro 8


            I don't know how to make sense of this??

            • 3. Re: Applescript "do script" command
              MarkWalsh Level 4

              I'm running under 10.4 as well at home. I'm not sure why that would be different in 10.5, perhaps there is a bug and applescript is trying to interpret the 'do script' command.


              I did notice that when I run the script, I get the same message as you are receiving if there is an error - if there is no document open, or the field being referenced does not exist (or is misspelled). I'll see if I can test it under 10.5 when I get to work tomorrow to see if I get the same results.

              • 4. Re: Applescript "do script" command
                MarkWalsh Level 4

                Came across this post: http://forums.adobe.com/thread/286675


                It seems that 'do script' is broken for Acrobat in Leopard, the workaround is to save the script out to a text file and run it from that file.

                • 5. Re: Applescript "do script" command
                  mmrm Level 1

                  Thanks for the reply.  That works except I'd like to include a variable determined earlier in the script.  The js command isn't the same every time.  How do I get around that if its a file?

                  • 6. Re: Applescript "do script" command
                    MarkWalsh Level 4

                    Have your script write the javascript out to the file.