Excel riporta un utente errato nella segnalazione che il file è bloccato per la modifica da un altro utente

Talvolta può  capitare che quando si apre un file Excel memorizzato su una share compaia l’avviso che il file è bloccato per la modifica da un altro utente, ma il nome utente riportato non sia corretto.

Excel , come del resto gli altri applicativi della suite Office, crea un  owner file crea quando viene aperto un documento, tale file è temporaneo e contiene il nome di accesso della persona che apre il documento. A rigurdo si veda questa la KB313472 “The document is locked for editing by another user” error message when you try to open a document in Word che sebbene sia riferita a World vale anche per Excel:

“Word creates an owner file when you open a previously saved Word document. An owner file is temporary and holds the logon name of the person who opens the document.”

 

“The owner file is located in the same folder as the document that you tried to open. The owner file name uses the following convention: It begins with a tilde (~), followed by a dollar sign ($), followed by the remainder of the document file name. The file name extension is .doc. For example, the owner file for Document.doc is named ~$cument.doc.”

Nel caso in cui il file temporaneo non venga eliminato alla chiusura del file per qualche problema si verifica il problema che viene riportato un utente errato nella segnalazione che il file è bloccato per la modifica da un altro utente o che venga riportato che il file è usato da altro utente quando non lo è, l’utente che viene indicato nel messaggio è quello che aveva aperto il file creando il file temporaneo che poi non non è stato eliminato alla chiusura.

Sempre nella KB313472 vengono riportate alcune possibili cause della mancata eliminazione del file temporaneo, come indicato precedentemente la KB sia riferisce a World, ma vale anche per Excel:

“Word previously quit improperly and, therefore, did not delete the owner file.”

 

“A second instance of Word is running in the background with the document already open.”

 

“The document is shared over a network, and another user has it open.”

Per risolvere il problema occorre eliminare il file temporaneo identificabile dal fatto il nome coincide col nome del file Excel, ma ha il prefisso ~$.

Per analizzare chi sta utilizzando i file su una share è possibile utilizzare la console nativa Computer Management (compmgmt.msc) oppure il comando openfiles:

openfiles /Query /fo csv | more

Per vedere ci sta utilizzando uno specifico file è possibile utilizzare il comando:

openfiles /Query /fo csv | find /i “filename.xlsx”

 

La visualizzazione dei file aperti è possibile anche tramite PowerShell mediante il cmdlet Get-SMBOpenFile che a differenza della console Computer Management e del comando

Get-SmbOpenFile|select ClientUserName,ClientComputerName,Path,SessionID

Un’altra alternativa è il tool grafico gratuito NetworkOpenedFiles sviluppato da NirSoft che fornisce varie informazioni tra cui Filename, user name, computer name, Permissions information (Read/Write/Create), locks count, file owner, file size, file attributes.