3 Replies Latest reply on Jan 31, 2010 9:54 AM by FentonJones

    Opening an external (word, excel, pdf...) file

    JurrasicParc

      Title

      Opening an external (word, excel, pdf...) file

      Post

      Hi,

      In FileMaker Pro 10 I want to open a file (located on a server) by clicking o a button. The file name is stored in a text field and the file path is fixed.

      The button has to work both in Windows and Mac clients.

      This should somehow mimick the effect of clicking on a container field (but without using a container field)

      Does any-one have an idea ?

       

        • 1. Re: Opening an external (word, excel, pdf...) file
          WoodApple
            

          you may not be able to do this quite the same on both os's but that is easy enough to work around...

           

          you need a script assigned to the button and look something like this

           

          If [ Abs(Get(SystemPlatform))=1 ] #Perform AppleScript ["<applescript text>"] Else Send Event [ open document/application; example::path ] [ Bring application to foreground ] End If

           

          not sure of what the applescript needs to be but I'd imagine it would be pretty easy to find. You will also need access to both OS's in order to set both the applescript and send event script steps. (send event = windows, Applescript = mac, only avalible on that os)
          • 2. Re: Opening an external (word, excel, pdf...) file
            JurrasicParc
              

            Thank you for the suggestion wich may be helpfull in quite a few situations, just that learning apple script and event script is just a bit too much for the purpose (and my patience!)

             

            I actually found an interseting way to do it:

             

            I created a mutlimedia field which serve just as a button, and I assigned an OnObjectEntry script to it. Let say that the file to be openend is :


                /Macintosh HD/XXX/YYY/ZZZ/myFile.doc

             

            and that directory YYY is mapped as "S" in windows, the script builds the following string (2 lines !) and assigne it to the multimedia field

             

              filewin:/S:/ZZZ/myFile.doc

              filemac:/Macintosh HD/XXX/YYY/ZZZ/myFile.doc

             

            Then double clicking the multimedia file opens it.

             

            This way you could even open a different file version depending on any criteria such as user right...

             

            • 3. Re: Opening an external (word, excel, pdf...) file
              FentonJones
                

              I think the easiest way is to create a FileMaker calculation field with a Container result, using your original file path.* Then use the standard script step, Go To Field [ Select/Perform ]. 

               

              The path needs to be a FileMaker syntax path, but this is not that hard to calculate. It will have a different prefix, "filemac:" or "filewin:", depending on platform. But you can easily figure that out using Abs (Get (SystemPlatform), which produces 1 for Mac, 2 for Windows.

               

              The other part which is different between the platforms is the name of the server. It is easy enough to see what that is by using Insert file on a Mac, then on a Windows machine. The resulting server name and syntax would then be included in the calculation, either hard-coded, or via a text field from a single-record Constants table.

               

              If you create a script to do this, then the field on the layout can be non-enterable. You can either show it on the layout, as the file name & icon, or just make it tiny, like 1 pixel, and hide it.

               

              Go to Field [ z_cFile_FM; Select/Perform ] 

              Commit Record [ no dialog ] 

               

               

              * Your original file path is what syntax? FileMaker? Mac? Windows? In any case you're going to need to dynamically convert it for the current user's platform, no matter what method you use to open it. Unless it can be served via a web server, in which case you could use a Web Viewer and OpenURL.