4 Replies Latest reply on Apr 22, 2010 5:52 PM by rjkkjr1

    Error opening pdf file, but then it still opens

    rjkkjr1 Level 1

      I am having trouble when I open a pdf.I am using the code below to open a pdf.

       

      on mouseUp me
        acro = bafindapp("pdf")
        if acro = empty then
          acrofile = me.pPDF
          alert "This program was unable to find a suitable program on your system to open a PDF document. It will open www.adobe.com, where you can download a free viewer"
          goToNetPage "http://www.adobe.com"
         
      else
          open the moviePath & "Resource\" & me.pPDF with acro
        end if
       
      end

       

      When this is on a button, adobe reader will open, but gives an error saying "There was an error opening this document. This file cannot be found."


      When I hit the ok button on the error notice, the pdf opens.

       

      Any ideas why I am getting this message even though the pdf opens after dismissing the message would be appreciated.

        • 1. Re: Error opening pdf file, but then it still opens
          Sean_Wilson Adobe Community Professional

          Since you're already using Buddy API, why not also use it to open the file:

          on mouseUp me
            acro = baFindApp("pdf")
            if ( acro = EMPTY ) then
              alert "This program was unable to find a suitable program on your system to open a PDF document. It will open www.adobe.com, where you can download a free viewer"
              goToNetPage "http://www.adobe.com"
            else
              -- Windows-only?
              tFile = _movie.path & "Resource\" & me.pPDF
              if baFileExists(tFile) then
                OK = baOpenFile(tFile, "normal")
                if ( OK < 32 ) then
                  -- see docs for numbers and their meaning
                  alert "Error opening file:" && OK
                end if
              else
                alert "File not found:" &RETURN& tFile
              end if
            end if
          end
          
          1 person found this helpful
          • 2. Re: Error opening pdf file, but then it still opens
            rjkkjr1 Level 1

            Wow, that response was quick.

             

            Sean, I can't thank you enough. That worked. If I might trouble you with just one more question. You wrote in there that it is windows only. How can I make the script work cross platform  on a mac and windows.

             

            Thank you for your time.

            • 3. Re: Error opening pdf file, but then it still opens
              Sean_Wilson Adobe Community Professional

              The reason I assumed, or asked, whether it was Windows-only is because of your use of the backslash character as the folder delimiter. To make the script cross-platform try the following:

              on mouseUp me
                acro = baFindApp("pdf")
                if ( acro = EMPTY ) then
                  alert "This program was unable to find a suitable program on your system to open a PDF document. It will open www.adobe.com, where you can download a free viewer"
                  goToNetPage "http://www.adobe.com"
                else
                  mPath = _movie.path
                  tFile = mPath & "Resource" & mPath.char[length(mPath)] & me.pPDF
                  if baFileExists(tFile) then
                    OK = baOpenFile(tFile, "normal")
                    if ( OK < 32 ) then
                      -- see docs for numbers and their meaning
                      alert "Error opening file:" && OK
                    end if
                  else
                    alert "File not found:" &RETURN& tFile
                  end if
                end if
              end
              • 4. Re: Error opening pdf file, but then it still opens
                rjkkjr1 Level 1

                Thank you Sean, this is exactly what I needed.