Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Excel File Already Open, Can't Copy To
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00582389
Message ID:
00582433
Views:
29
You can use FOPEN() function to check if a file has been released by another program
lnFileHandle = FOPEN('myfile.txt',12)  
IF lnFileHandle < 0  
	* Cannot open file 
ELSE  
	* File is not in use. 
	=FCLOSE(lnFileHandle)  
ENDIF
>I have an app that generates Excel reports using "COPY TO (lcFile) TYPE XL5" where "lcFile" is a filename generated by the date (ie. "report_20011225.xls"). If someone runs the report, which automatically opens in Excel, then keeps it open and later re-runs it (happens very often) then they get a "LOCK FILE VIOLATION" error and the new report can't open. How can I check to see if a file is open already? I tried using an error handler to change the filename, but keep getting a MISMATCHED PUSH/POP error. There has to be a better way...
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform