Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Testing for an open file

I have an application that appends a log to a CSV file as each instance of
the application ends. The CSV is used by others on an infrequent basis to
check on the log. The CSV file sits on a shared server/directory for this
purpose.

Usually the coincidence of the application ending and the CSV being open is
very rare (never happended in 18 months -so far!). The problem arises when
the CSV is left open as recently happended in this case the application
failed as it couild not write to the CSV file. My application needs to
detect this, issue a warning and wait for the CSV to be released or store
the log locally and append it next time the application is run.

How can I detect if a CSV is open and therefore not available to be updated?
Also is it possible to identify the user who has the file open, in a similar
way that Excel warns if an Excel Workbook is open?


--
Cheers
Nigel




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 230
Default Testing for an open file

Try this:

Open it for APPEND, append your username to the bottom, close it

Open it, go to EOF, look for your username. If it is there, you own the
file.

If it is not there, consider yourself locked out.

Remember to remove your username!

Bill

"Nigel" wrote in message
...
I have an application that appends a log to a CSV file as each instance of
the application ends. The CSV is used by others on an infrequent basis to
check on the log. The CSV file sits on a shared server/directory for this
purpose.

Usually the coincidence of the application ending and the CSV being open
is
very rare (never happended in 18 months -so far!). The problem arises
when
the CSV is left open as recently happended in this case the application
failed as it couild not write to the CSV file. My application needs to
detect this, issue a warning and wait for the CSV to be released or store
the log locally and append it next time the application is run.

How can I detect if a CSV is open and therefore not available to be
updated?
Also is it possible to identify the user who has the file open, in a
similar
way that Excel warns if an Excel Workbook is open?


--
Cheers
Nigel






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Testing for an open file

Here is what Microsoft recommends:

http://support.microsoft.com?kbid=138621
XL: Macro Code to Check Whether a File Is Already Open

http://support.microsoft.com?kbid=291295
XL2002: Macro Code to Check Whether a File Is Already Open

http://support.microsoft.com?kbid=213383
XL2000: Macro Code to Check Whether a File Is Already Open

http://support.microsoft.com?kbid=184982
WD97: VBA Function to Check If File or Document Is Open

I haven't seen anything on detecting who has the file open, but that might
be possible using the Windows API or related.

--
Regards,
Tom Ogilvy

"Nigel" wrote in message
...
I have an application that appends a log to a CSV file as each instance of
the application ends. The CSV is used by others on an infrequent basis to
check on the log. The CSV file sits on a shared server/directory for this
purpose.

Usually the coincidence of the application ending and the CSV being open

is
very rare (never happended in 18 months -so far!). The problem arises

when
the CSV is left open as recently happended in this case the application
failed as it couild not write to the CSV file. My application needs to
detect this, issue a warning and wait for the CSV to be released or store
the log locally and append it next time the application is run.

How can I detect if a CSV is open and therefore not available to be

updated?
Also is it possible to identify the user who has the file open, in a

similar
way that Excel warns if an Excel Workbook is open?


--
Cheers
Nigel






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Testing for an open file

Thanks for the information - very useful

--
Cheers
Nigel



"Tom Ogilvy" wrote in message
...
Here is what Microsoft recommends:

http://support.microsoft.com?kbid=138621
XL: Macro Code to Check Whether a File Is Already Open

http://support.microsoft.com?kbid=291295
XL2002: Macro Code to Check Whether a File Is Already Open

http://support.microsoft.com?kbid=213383
XL2000: Macro Code to Check Whether a File Is Already Open

http://support.microsoft.com?kbid=184982
WD97: VBA Function to Check If File or Document Is Open

I haven't seen anything on detecting who has the file open, but that might
be possible using the Windows API or related.

--
Regards,
Tom Ogilvy

"Nigel" wrote in message
...
I have an application that appends a log to a CSV file as each instance

of
the application ends. The CSV is used by others on an infrequent basis

to
check on the log. The CSV file sits on a shared server/directory for

this
purpose.

Usually the coincidence of the application ending and the CSV being open

is
very rare (never happended in 18 months -so far!). The problem arises

when
the CSV is left open as recently happended in this case the application
failed as it couild not write to the CSV file. My application needs to
detect this, issue a warning and wait for the CSV to be released or

store
the log locally and append it next time the application is run.

How can I detect if a CSV is open and therefore not available to be

updated?
Also is it possible to identify the user who has the file open, in a

similar
way that Excel warns if an Excel Workbook is open?


--
Cheers
Nigel








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
testing. do not open. S S Excel Worksheet Functions 1 April 16th 06 01:16 AM
testing for the name of the file James[_23_] Excel Programming 0 May 26th 04 09:45 AM
Testing if a file is open John Baker Excel Programming 3 January 29th 04 01:26 AM
Testing for a open worksheet from Outlook Phillips[_3_] Excel Programming 1 December 30th 03 07:45 AM
Testing for open workbook nigelab Excel Programming 4 November 2nd 03 04:31 PM


All times are GMT +1. The time now is 03:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"