Check to see if XL file is opened

KGee

Well-known Member
Joined
Nov 26, 2008
Messages
539
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I need to check if files on a network share are in use or otherwise locked by some process. If the file being checked is in use, I would also like to get the name of the user who has the file open. I've found code that tells me if the files I need are in use but I still need to determine who has them open.

The examples I've found follow the basic syntax below to test if the files are in use:
Code:
Open file_in_question For Binary Access Read Write Lock Read Write As #filenum
or
Open file_in_question For Input Lock Read As #filenum
Does anyone have an example they can share that will give me the user name as well?
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
There's an article here that might help.

http://www.xcelfiles.com/IsFileOpen.html#anchor_37

The Microsoft page for IsFileOpen

http://support.microsoft.com/kb/291295
Thanks for the links, these are two that I already found while I was searching. I thought the first link was promising but I received inconsistent results. I tested by opening a few different files and sometimes it showed my name (my full name and not my network login), other times it was blank, and I also received something wierd like "a satisfied MS office user". The "satisfied user" message was when I tried with an Excel file which was output from another program. Which has me thinking if the LastUser property has the information I need to begin with.

Thanks again.
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,345
Members
452,907
Latest member
Roland Deschain

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top