Jump to content
Macro Express Forums

PDF still open

Recommended Posts

I have a macro that copies PDF file from one server to another.  The problem I am having is that sometimes a PDF file is still being copied to the server when the macro run.  

1. A document is scanned and saved as a PDF to server1

2. A macro runs every few minutes on server1 and copies the PDF to server2

3. Occasionally, at PDF is in the middle of being saved to server1 when the macro tries to move it to server2.  This causes a window error or even a corrupt PDF file.

Is there a way to tell is a PDF is ready to be moved?  The "IF file Ready" command won't work because it only test

Any ideas?

Move file one-at-a-time.mxe

Share this post

Link to post
Share on other sites

Maybe have the macro check file date and time, and only attempt to copy those that are a few minutes old???  Those not old enough will presumably be processed the next time the macro runs.  Command "Variable Set from File" can be used to obtain file information. 

Share this post

Link to post
Share on other sites

Try the Wait for File to be Ready command.

If Folder Exists: "\\SCANSERVERHOST\PPLImageDepot\Processing Temp"
  Repeat with Folder C:\Scans // PLow thru the folder
    Clear Variables
    Variable Set From File path // Get teh file extension
    Variable Set From File: Set to the Size of a File (C:\Scans\%File%)
    If File Exists: "C:\Scans\%File%"
      If Variable %Size% Is Greater Than "0"
        Wait for File to be Ready: C:\Scans\%File%
        Copy File/Files: "C:\Scans\%File%" to "c:\Scans Sav"
        Move File/Files: "C:\Scans\%File%" to "\\SCANSERVERHOST\PPLImageDepot\Processing Temp\%File%"
        On Error
          Catch Error: File could not be located
            Macro Stop
          End Catch Error
        End Error
      End If
    End If
  End Repeat
End If


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now