VBA - capture ID of user with File Reservation, and then re-use in MSG box

Gerald Higgins

Well-known Member
Joined
Mar 26, 2007
Messages
9,258
Hi all - thanks in advance for any help.

I have an application which basically works fine, but I am looking at making some improvements.

One thing it does is try to work with other files held on network servers.

Occasionally, these files have already been opened by another user, and so the application is unable to open them in their read/write version, which is what I need.
I have got code which can get round this by either ignoring that type of error, or getting the application to fall over in a controlled way.

What I'd really like to do however (and am struggling with) is display a message to the user that the file is already in use, and include the other user's ID in that message, so that the person using my application can contact that person and get them to close the file. I think I could just use the standard message that Excel gives you in that situation, but I'd prefer not to, partly because that includes an option to open a read-only version, which I don't want the users to select.

The way I see this working, is that the application would (try to) open all the required files at the start of the task, and if it reached a problem with any of them it would display a clear message to the user, identifying the other user, and then shut down. IF all the required files were opened successfully, only then would it go on to perform the main tasks.

Any ideas on this ?

Thanks again in advance for any help.
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

Forum statistics

Threads
1,215,036
Messages
6,122,796
Members
449,095
Latest member
m_smith_solihull

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