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

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
 
S

STEVE BELL

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

If ActiveWorkbook.ReadOnly Then ActiveWorkbook.Close FalseEnd If
 
Joined
Aug 8, 2017
Messages
2
Reaction score
0
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
 
Joined
Aug 8, 2017
Messages
2
Reaction score
0
this is the tree in VBA and I created the module off ThisWorkbook
upload_2017-8-10_10-51-20.png
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top