How can I know who hasn't closed the file? (1 Viewer)

Etxezarreta

Member
Local time
Today, 08:56
Joined
Apr 13, 2020
Messages
175
Hello everyone,
I have folders and subfolders that contains different files: pdf, autocads etc.. Before I move one folder, I need to make sure that all the files in the folders are closed, and to know who is the user that hasn't closed his files. Would you have any suggestion please?
Many thanks in advance.
Etxe.
 

conception_native_0123

Well-known member
Local time
Today, 01:56
Joined
Mar 13, 2021
Messages
1,834
i doubt you can do this with code, and even if you could it would be very difficult. macros certainly can't do it. you're talking about other files outside of office files, which is why the answer is probably no. it's more of a windows question than access i believe.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 23:56
Joined
Oct 29, 2018
Messages
21,454
Hello everyone,
I have folders and subfolders that contains different files: pdf, autocads etc.. Before I move one folder, I need to make sure that all the files in the folders are closed, and to know who is the user that hasn't closed his files. Would you have any suggestion please?
Many thanks in advance.
Etxe.
See if you can use this one.

Get username of open file (.xlsx & .pdf) | MrExcel Message Board
 

Isaac

Lifelong Learner
Local time
Yesterday, 23:56
Joined
Mar 14, 2017
Messages
8,774
Hello everyone,
I have folders and subfolders that contains different files: pdf, autocads etc.. Before I move one folder, I need to make sure that all the files in the folders are closed, and to know who is the user that hasn't closed his files. Would you have any suggestion please?
Many thanks in advance.
Etxe.
what kinds of files are they? some programs like excel produce a temporary file that indicates a file is open: ~$filename
 

Sun_Force

Active member
Local time
Today, 15:56
Joined
Aug 29, 2020
Messages
396
The title says "the file" which points to a specific file, but your explanation says: "I need to make sure that all the files in the folders are closed"
I go for the hard (second) one:

when you say different users opening the same files, I think you are on a windows network with a server for file sharing.
If this is the case you can do it in vba and possibly with macros. This is the vba method. you can convert it to macro:

Preparation:
  1. Open notepad
  2. Add the following lines and save it anywhere you want (I chose D:\OpenFiles.txt).
    openfiles /Query /s Server /fo csv
    pause
  3. Change the Sever to your Server name.
  4. Change the extension of the file to cmd. Now you have D:\OpenFiles.cmd

Usage:

Now in vba if you run the following code, you'll receive a list of all opened files along with their ID/machine names/users who are using shared files
Code:
Dim ret
ret = Shell("D:\OpenFiles.cmd", vbNormalFocus)

Now using the ID of the file, you can even close the files with the same method.

Notes:
  • Your account should be a member of admin group or find a way to run the cmd file with admin privilege.
  • If you are on a windows domain, you can even open computer management on your server, and go to system tools/Shared folders/open files, add a console form there to a shared folder. Copy/move it to your PC and run it. You can view a list of all opened files. You can even close one or all of them with a simple click
 
Last edited:

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 01:56
Joined
Feb 28, 2001
Messages
27,140
Now the other side of this. Sun_Force's solution works if you have admin rights, but MIGHT also work if you have full permissions on the files and the specific folder that is of interest to you. Ever since the advent of Windows NT a couple of decades ago, Microsoft has been trying to lock down security issues due to the previously wide-open nature of Windows. Seeing what other people are doing requires you to have EITHER admin privilege in general, or ownership permissions on the folder and files in question. And I won't guarantee that ownership will always do it if you are talking about network-level access.

Some utilities give you hints, like the .LDB file from Access or the $Filename file from Excel. But in general, only Windows can tell you, and it is generally disinclined to do so unless you are the boss. It's just a fact of life that Windows isn't as forthcoming as it used to be.
 

Etxezarreta

Member
Local time
Today, 08:56
Joined
Apr 13, 2020
Messages
175
The title says "the file" which points to a specific file, but your explanation says: "I need to make sure that all the files in the folders are closed"
I go for the hard (second) one:

when you say different users opening the same files, I think you are on a windows network with a server for file sharing.
If this is the case you can do it in vba and possibly with macros. This is the vba method. you can convert it to macro:

Preparation:
  1. Open notepad
  2. Add the following lines and save it anywhere you want (I chose D:\OpenFiles.txt).
    openfiles /Query /s Server /fo csv
    pause
  3. Change the Sever to your Server name.
  4. Change the extension of the file to cmd. Now you have D:\OpenFiles.cmd

Usage:

Now in vba if you run the following code, you'll receive a list of all opened files along with their ID/machine names/users who are using shared files
Code:
Dim ret
ret = Shell("D:\OpenFiles.cmd", vbNormalFocus)

Now using the ID of the file, you can even close the files with the same method.

Notes:
  • Your account should be a member of admin group or find a way to run the cmd file with admin privilege.
  • If you are on a windows domain, you can even open computer management on your server, and go to system tools/Shared folders/open files, add a console form there to a shared folder. Copy/move it to your PC and run it. You can view a list of all opened files. You can even close one or all of them with a simple click
It looks promising: as I don't have access to the server for a couple of weeks, I 'd like to run a few trials in my local computer.
How should I adapt the following code please?
Many thanks!
Code:
openfiles /Query /s Server /fo csv
pause
 

Etxezarreta

Member
Local time
Today, 08:56
Joined
Apr 13, 2020
Messages
175
i doubt you can do this with code, and even if you could it would be very difficult. macros certainly can't do it. you're talking about other files outside of office files, which is why the answer is probably no. it's more of a windows question than access i believe.
I keep you updated about the answer!
 

Users who are viewing this thread

Top Bottom