Suppose you have a XLSM that needs to open a XLSX and have exclusive access to it. However if you are working on a network, there is the possibility that another user already has this XLSX open.
I already have code that will detect if another user has the XLSX open or not. The problem I have is finding a way to determine the name of the user that is currently using this workbook.
What I have tried so far:
1. WriteReservedBy = No point discussing this one further. It doesn't work (websites say so + I tested myself).
2. I found a custom function that looked extremely promising (see code at end of this post) but when tested it couldn't return the name of the user (the strXL returned a complete mess. There was no readable name in it).
My current idea for solving (but I would like help on):
I notice that when another user has a workbook open on a network, Windows creates a hidden workbook while it is open. This hidden workbook exists in the same directory and has the same file name but with a prefix of "~$" added. Now the interesting thing is this: If you look at file properties (in Windows Explorer) the Owner property for the open Workbook remains that of the creator. However the Owner property for the hidden workbook is that of the user who currently has the workbook open. So how do I get the code to return this?
APPENDIX:
This is the code that didn't return the user name. However the LastUser function could be replaced with my idea above.
Bookmarks