3 Replies Latest reply on Sep 2, 2009 4:20 PM by Sean_Wilson

    Can someone help me with this powerpoint viewer with director issue?

    merlin66043

      I have 'inherieted' an interactive CD that was built using director mx2004.  I get presentations from different people and put them on a CD to hand out at the end of a seminar. For the Power Point presentations I have director use the powerpoint viewer just in case someone does not have PowerPoint on there machine.  This works fine, but I have been getting people that are using PowerPoint 2007 which uses a different extension (pptx instead of ppt).  I also have word documents, adobe pdf, ect.  Here is the code that handles how to open up the files, whether using PPT viewer or the default program. wasn't sure if you needed all of this or not.

       

      --RUNS WHEN MAIN OPEN BUTTON IS PRESSED--
      on mouseUp me
        --if button 1-5 has been clicked
        if(_global.btnNum = 0 or _global.btnNum = 1 or _global.btnNum = 2 or _global.btnNum = 3 or _global.btnNum = 4 ) then
          --assign selected file to a variable
          selectedFile = sprite("listBox").selectedItem.data
         
          --path of the file that is selected
          filePath = "workshops\days\day" & _global.btnNum & "\" & selectedFile
          --find out the type of file
          fileExt = selectedFile.char[(selectedFile.length-2)..selectedFile.length]
        end if
       
        --if file is classified secret and not provided on this disc (must have "*" at data end)
        if(selectedFile.char[selectedFile.length] = "*") then
          --set file to placeholder.ppt (since it has an * at data end)
          filePath = "workshops\placeholder.ppt"
          --set file extension to ppt (since it has an * at data end)
          fileExt = "ppt"
        end if
       
        if(fileExt = "ppt")  then
          --opens file in powerpointviewer
          _player.open(filePath & " /S", "launchers\PPTVIEW.EXE")
          else
          --opens file in the default program on that computer
          _player.open(filePath, "launchers\PLAY.EXE")
        end if
      end

       

      I have been trying to get the pptx files to also open in the viewer.  I have been able to do this, but the problem is it wants to try to open everything in viewer.

       

      Here is what I have tried:

      1- This wants to open everything in PPT viewer.  Not sure why.

      if(fileExt = "ppt" or "pptx")  then
           --opens file in powerpointviewer
           _player.open(filePath & " /S", "launchers\PPTVIEW.EXE")
           else
           --opens file in the default program on that computer
           _player.open(filePath, "launchers\PLAY.EXE")
         end if
      end

       

      2-This will just open the 'pptx' file in Power Point.  I am sure I am using the 2007 version of PPT viewer in director.

       

      if(fileExt = "ppt")  then
          --opens file in powerpointviewer
          _player.open(filePath & " /S", "launchers\PPTVIEW.EXE")
        else if(fileExt = "pptx") then
          --opens file in powerpointviewer
        _player.open(filePath & " /S", "launchers\PPTVIEW.EXE")
        else
          --opens file in the default program on that computer
          _player.open(filePath, "launchers\PLAY.EXE")
        end if
      end

       

      I am not sure where to go from here.  Can someone help me?  Have not been using director for very long.

       

      Thanks

        • 1. Re: Can someone help me with this powerpoint viewer with director issue?
          Sean_Wilson Adobe Community Professional

          It's unclear what exactly is the problem: is it managing to distinguish and open PowerPoint 2007 (*.pptx) files, or is it that every file tries to run in PPTView.exe?

           

          Part of your problem might be that .pptx is 4 characters long, while .ppt is only 3, and the code dealing with the file extension:

          fileExt = selectedFile.char[(selectedFile.length-2)..selectedFile.length]

          will only grab the last 3 characters regardless of where the "." is.

          Create a new #movie script member (press Ctrl + Shift + U and then hit the + button - "New Cast Member" - at the top-left of the script window that opens). Set the script syntax to JavaScript by altering the drop-down just below the + button and paste in the following:

          function jsGetExtension(fName){
            if(typeof(fName)!="string") return "";
            return fName.split(".").pop();
          }
          

          Then use the following modification to your original script:

          global btnNum
          
          --RUNS WHEN MAIN OPEN BUTTON IS PRESSED--
          on mouseUp me
            --if button 1-5 has been clicked
            case btnNum of
              0, 1, 2, 3, 4:
                --assign selected file to a variable
                selectedFile = sprite("listBox").selectedItem.data
                
                --path of the file that is selected
                filePath = "workshops\days\day" & btnNum & "\" & selectedFile
                --find out the type of file
                fileExt = jsGetExtension(selectedFile)
            end case
            
            --if file is classified secret and not provided on this disc (must have "*" at data end)
            if (selectedFile.char[selectedFile.length] = "*") then
              --set file to placeholder.ppt (since it has an * at data end)
              filePath = "workshops\placeholder.ppt"
              --set file extension to ppt (since it has an * at data end)
              fileExt = "ppt"
            end if
            
            case fileExt of
              "ppt", "pptx":
                --opens file in powerpointviewer
                _player.open(filePath & " /S", "launchers\PPTVIEW.EXE")
              otherwise:
                --opens file in the default program on that computer
                _player.open(filePath, "launchers\PLAY.EXE")
            end case
          end
          

           

          However, I'm nervous that you aren't supplying the full path to files and executables. I don't know where the movie file that contains this code is relative to the folder "launchers\" or "workshops\" put I suggest you prepend the movie's full path (or the application's full path) like so:

          global btnNum
          
          --RUNS WHEN MAIN OPEN BUTTON IS PRESSED--
          on mouseUp me
            mPath = _movie.path -- OR _player.applicationPath
            --if button 1-5 has been clicked
            case btnNum of
              0, 1, 2, 3, 4:
                --assign selected file to a variable
                selectedFile = sprite("listBox").selectedItem.data
                
                --path of the file that is selected
                filePath = mPath & "workshops\days\day" & btnNum & "\" & selectedFile
                --find out the type of file
                fileExt = jsGetExtension(selectedFile)
            end case
            
            --if file is classified secret and not provided on this disc (must have "*" at data end)
            if (selectedFile.char[selectedFile.length] = "*") then
              --set file to placeholder.ppt (since it has an * at data end)
              filePath = mPath & "workshops\placeholder.ppt"
              --set file extension to ppt (since it has an * at data end)
              fileExt = "ppt"
            end if
            
            case fileExt of
              "ppt", "pptx":
                --opens file in powerpointviewer
                _player.open(filePath & " /S", mPath & "launchers\PPTVIEW.EXE")
              otherwise:
                --opens file in the default program on that computer
                _player.open(filePath, mPath & "launchers\PLAY.EXE")
            end case
          end
          
          • 2. Re: Can someone help me with this powerpoint viewer with director issue?
            Sean_Wilson Adobe Community Professional

            I forgot to suggest: instead of using the "native" _player.open() command you would be better served by using an xtra (like Buddy API) that can provide you feedback about the success of the open() command and reasons for failure if it doesn't work.

            • 3. Re: Can someone help me with this powerpoint viewer with director issue?
              Sean_Wilson Adobe Community Professional

              I took the liberty of re-working your code to use Buddy API. It has 2 advantages over the original in that it verfies that files and applications exist before trying to open/run anything, and if the run operation fails you will be notified (with the ability to determine why it failed):

              global btnNum
              
              --RUNS WHEN MAIN OPEN BUTTON IS PRESSED--
              on mouseUp me
                mPath = _movie.path -- OR _player.applicationPath
                --if button 1-5 has been clicked
                case btnNum of
                  0, 1, 2, 3, 4:
                    --assign selected file to a variable
                    selectedFile = sprite("listBox").selectedItem.data
                    --path of the file that is selected
                    filePath = mPath & "workshops\days\day" & btnNum & "\" & selectedFile
                    --find out the type of file
                    fileExt = jsGetExtension(selectedFile)
                end case
                
                --if file is classified secret and not provided on this disc (must have "*" at data end)
                if (selectedFile.char[selectedFile.length] = "*") then
                  --set file to placeholder.ppt (since it has an * at data end)
                  filePath = mPath & "workshops\placeholder.ppt"
                  --set file extension to ppt (since it has an * at data end)
                  fileExt = "ppt"
                end if
                
                case fileExt of
                  "ppt", "pptx": sApplication = mPath & "launchers\PPTVIEW.EXE"
                  otherwise:     sApplication = mPath & "launchers\PLAY.EXE"
                end case
                
                me.mOpenDocument(filePath, sApplication)
              end
              
              on mOpenDocument me, aFile, anApplication
                sApp = baShortFilename(anApplication)
                if ( sApp = EMPTY ) then
                  -- application doesn't exist (path might be wrong - try _player.applicationPath instead)
                  alert "Application not found:" &RETURN& anApplication
                  exit
                end if
                
                sFile = baShortFilename(aFile)
                if ( sFile = EMPTY ) then
                  -- file doesn't exist (path might be wrong - try _player.applicationPath instead)
                  alert "File not found:" &RETURN& aFile
                  exit
                end if
                
                OK = baRunProgram(sApp && sFile, "normal", 0)
                if ( OK < 32 ) then
                  -- error running application - check BudAPI docs for numbers and their meaning:
                  alert "Error opening file:" && OK
                end if
              end
              

               

              You will also need the JavaScript movie level handler I posted earlier to make this work.

               

              Also, be sure to make the Buddy API xtra available for your projector when published. I would recommend using a so-called stub projector and external xtras folder to make this all easier - see Dean Utian's tutorial for more information about this.