stop excel file opened as read only if already opened by another u

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hello,

how do i prevent an excel file being opened as read only if the file is
already opened by another user. this particular file is on the file server
and accessed by multiple users.

What I want is an alert if the file is already opened which says the file
cannot be opened as read only and click ok to close. the alert to inlcude the
username who has the file opened.

workbook sharing is not an option as it breaks my various vba macros

appreciate any help...

cheers
 
Play with this code (place it in your wb open code)

If ActiveWorkbook.ReadOnly Then ActiveWorkbook.Close FalseEnd If
 
Hi,
I'm totally new to VB and I saw this earlier post which looks perfect for resolving my issue.
On my workbook I've created a module and added in this statement

If ActiveWorkbook.ReadOnly Then ActiveWorkbook.Close FalseEnd

I keep getting Compile error:
Invalid outside procedure

can anyone tell me where I'm going wrong?
many thanks
 
this is the tree in VBA and I created the module off ThisWorkbook
upload_2017-8-10_10-51-20.webp
 
Back
Top