2 Replies Latest reply on Apr 13, 2011 4:59 AM by RobertRosenow

    Check to see if file exists before saving

    DanielClark

      Title

      Check to see if file exists before saving

      Post

      I am using FM's built-in save as pdf feature - which is wonderful - but I want to check to see if a file exists at the specified path I'm saving it to (the path is stored in a variable called $FilePath) before I save it. If it does exist, I want to skip the save as pdf step. How do I do this? Can I do this? Thanks.

        • 1. Re: Check to see if file exists before saving
          philmodjunk

          I think you'd need to get one of the file plug ins in order to do this.

          You can almost do this by trying to insert the file into a container field and trapping for errors. If there's an error, the file doesn't exist. Unfortunately, if the $Path variable doesn't point to a file that exists, insert file insists on opening up a dialog for the user to to find and insert the file--so that doesn't quite get us there. Undecided

          • 2. Re: Check to see if file exists before saving
            RobertRosenow

            You can accomplish this by inserting a Send Event step to open your $FilePath\$Filename, and capture the error.  If the file does not exist, Get(Last Error) will be 100. 

            The only downside to this approach is that if the file DOES exist, it will open in the foreground or background as you selected in the Send Event.  The answer to this is a second Send Event to call a separate external program in Basic or C to close the application used to open the file in the first Send Event.