in reply to Lock on file

You may have to dive into the innards of the Windows API to solve your problem. There is a Windows API function (which does not seem to be implemented in the version of the Win32 module in ActiveStates' 5.8.7 build), LockFileEx which implements strict file locking.

I believe that Excel grabs exclusive access to a file it has open, but this may not be honored when a file is being pulled from a different machine, so you shouldn't be able to copy it while the file is open in Excel. Testing this should be easy; have somebody open the file in Excel and try running your copy job while it's open.

There are also ways -- using the Windows API -- to check to see if a file is being used by another process. One I've used is to try to open the file for exclusive access with _lopen (this is via a C++ routine). If you cannot open it exclusively, somebody else currently has it open.

emc

" When in doubt, use brute force." — Ken Thompson