Shared Workbook

G

GeoffG

I've written VBA code to open a shared Workbook and make changes. I need my
code to determine whether another user has the Workbook open and whether, as
a consequence, my code is opening a read-only copy of the Workbook - in
which case, the code needs to abandon making changes, with advice to the
user to try again later.

Can I programmatically attempt to open a workbook in exclusive mode and then
see if the Workbook opened? Or is there a property I can examine after the
Workbook has opened to determine whether it's in read-only mode?

TIA
Geoff.
 
M

Mark Ivey

Here is another idea from http://www.mvps.org/dmcritchie/excel/readonly.htm


Who Has the Read Only File (#reserved)
Macro supplied by Harald Staff, Programming, 2002-10-14.
Sub test()
Dim wbk As Workbook
Set wbk = Workbooks.Open("C:\temp\book1.xls")
If wbk.ReadOnly Then
MsgBox "Write reserved by " & _
wbk.WriteReservedBy
End If
End Sub
 
N

NickHK

Geoff,
Do you Shared in the Excel sense or shared as in more the one person uses
the WB ?
Understanding the difference may help you.
Make sure you understand the consequences of <Excel Sharing> before you
apply it.

NickHK
 

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