7 Replies Latest reply on Oct 18, 2010 9:38 AM by Ranjaxt2012

    export to excel trusted function error.

    Ranjaxt2012

       

      i understand than it is a trusted/folder level scripting function problem but can some one help me getting thought. another question, is there any way i can avoid this security message, can i totally turn off my security so that i can write a simple program and not have to go worry about all the trusted functions. Sorry for many postings, but this is very frustrating environment for a developer.

       

       

       

      app.addToolButton({
                 cName: "exptoexcel",

       

                 cExec: "myExport()",

       

                 cLabel: "Excell Exp",

       

                 cTooltext: "Creat Redar Links"
          });

       

       

      function myExport ()
      {
      app.trustedFunction(checkReport(this));


      }

       

       

      function exportMyReport(doc)
      {
      var annots = doc.getAnnots();

       

          var myExpFile = "Name\tPage\tComment";

       

          for ( var i=0; i<annots.length; i++ )

       

              myExpFile += ("\n"+annots[i].author + "\t" + annots[i].page + "\t\""

       

                  + annots[i].contents+"\"");

       


          doc.createDataObject({cName: "myCommentList.xls", cValue: cMyC});

       

          doc.exportDataObject({cName: "myCommentList.xls", nLaunch: 1});
      }

       

      error message is

       


      NotAllowedError: Security settings prevent access to this property or method.
      App.trustedFunction:14:App exptoexcel:Exec

        • 1. Re: export to excel trusted function error.
          try67 MVP & Adobe Community Professional

          No, you can't turn off the security restrictions.

          You're not using the trustedFunction method correctly. Look at the reference

          to see how it's done properly.

          Another thing is you're calling checkReport in trustedFunction, while the

          name of your function is actually exportMyReport.

          Also, where do you define the parameter "cMyC" that you use in

          createDataObject ?

          And just as a general remark, you're better off exporting to a CSV file. XLS

          is a proprietry format and you can't just create a valid XLS file like that.

          CSV, on the other side, is a simple comma separated text file, which Excel

          recognizes without any problems.

          1 person found this helpful
          • 2. Re: export to excel trusted function error.
            Ranjaxt2012 Level 1

            Thanks i will pay attention to the other export format.

            so one is working and other one is not.

             

            can u tell me what am i doing wrong with more explanation.

             

             

            function myExport ()
            {
            app.trustedFunction(checkReport(this)); // working
            app.trustedFunction(exportMyReport(this)); //not working
            }

             

            function myExport ()
            {
            app.trustedFunction(checkReport(this));
            app.trustedFunction(exportMyReport(this));
            }

             

            function checkReport(doc)
            {
            for (var i = 0; i < doc.numPages; i++)
            {

             

            var numWords = doc.getPageNumWords(i);
                for(var j = 0; j < numWords; j++)

             

                {
                    var wordCount = doc.getPageNthWord(i,j);
               
                    if (wordCount == "Firm")
                    {
                            var wc = j;
                    }
                    }
            for(var w = 0; w < wc; w++)
            {
                    ckWord = doc.getPageNthWord(i,w);
               
                    if (ckWord == "ECM")

             

                {

             

                            doc.addAnnot
                    ({
                    page: i,

             

                    type: "StrikeOut",

             

                    quads: doc.getPageNthWordQuads(i,w),

             

                    author: "Anup Singh",

             

                    contents: ckWord.toString()

             

                    });
              
            }//wc ends
                } //end PRR statement
            }// end word loop
            }//end of finction

             


            function exportMyReport(doc)
            {
            var annots = doc.getAnnots();

             

                var myExpFile = "Name\tPage\tComment";

             

                for ( var i=0; i<annots.length; i++ )

             

                    myExpFile += ("\n"+annots[i].author + "\t" + annots[i].page + "\t\""

             

                        + annots[i].contents+"\"");

             


                doc.createDataObject({cName: "myCommentList.xls", cValue: cMyC});

             

                doc.exportDataObject({cName: "myCommentList.xls", nLaunch: 2});
            }

            • 3. Re: export to excel trusted function error.
              try67 MVP & Adobe Community Professional

              Does your file has file attachment rights?

              • 4. Re: export to excel trusted function error.
                Ranjaxt2012 Level 1

                i am not sure about file attachment. however it saves my data and launches it for me. if you want to call it file attachment then....

                • 5. Re: export to excel trusted function error.
                  Ranjaxt2012 Level 1

                  i think the problem is with trusted function.

                  • 6. Re: export to excel trusted function error.
                    gkaiseril MVP & Adobe Community Professional

                    Where have you established the object of the 'doc' object?

                     

                    You might want to look at line 14 of your script and possibly place a 'console.println();' with some information about the variables you are trying to use in line 14.

                     

                    Where is the "checkReport()' function defined?

                    1 person found this helpful
                    • 7. Re: export to excel trusted function error.
                      Ranjaxt2012 Level 1

                       

                      thanks all its working. your help is highly appreciated.