Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Shared Workbook

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.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default Shared Workbook

I would run this one from Ozgrid first and have it return a TRUE or FALSE to
decide on the rest of your code...


http://www.ozgrid.com/VBA/IsWorkbookOpen.htm#ONE




"GeoffG" wrote in message
...
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.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default Shared Workbook

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













"GeoffG" wrote in message
...
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.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Shared Workbook

Hi Mark:

Many thanks for your reply. The Harald Staff code seemed promising but
result was unexpected.

VBA code running in Workbook1 opens Workbook2, with an object variable
"objWBK2" pointing to Workbook2.

As expected, if no one else on the network has Workbook2 open, then:

objWBK2.ReadOnly = False

And, if someone else does have Workbook2 open, then:

objWBK2.ReadOnly = True.

Also, if someone else has Workbook2 open, Excel suspends the VBA program to
display a dialog telling me the name of the user who has Workbook2 open. On
clicking the "Read Only" button, my VBA program continues to open Workbook2.

But the next bit was unexpected. If the ReadOnly property is True (ie
someone else has Workbook2 open), I would have expected:

objWBK2.WriteReservedBy

to return the name of the user who has Workbook2 open. But in fact, it
returns my name, ie the name of the user who has Workbook1 open, ie where
the code is running. (Notice, the above line specifically asks for the
WriteReserveBy property of Workbook2.)

Any thoughts?

TIA
Geoff


"Mark Ivey" wrote in message
...
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













"GeoffG" wrote in message
...
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.






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Shared Workbook

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

"GeoffG" wrote in message
...
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.






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Shared Workbook

Hi Nick:

I'm afraid I don't know what the Excel sense is. (If you can help me with
that or point to information on the web, I'd be grateful.)

I was referring to a Workbook stored on a network server that is shared (ie
updated) by more than one person on the network. The Workbook only allows
one person at a time to make changes.

TIA
Geoff



"NickHK" wrote in message
...
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

"GeoffG" wrote in message
...
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.






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
shared workbook is set up is not 'shared' on network moviemaker novice Excel Worksheet Functions 0 April 7th 10 03:31 AM
shared workbook - shared workbook options grayed out Edward Letendre Excel Discussion (Misc queries) 0 March 3rd 10 10:47 PM
Printing viewing a shared workbook on a shared drive aloomba Excel Discussion (Misc queries) 0 April 13th 07 02:52 PM
update pivot in shared shared workbook 00George00 Excel Discussion (Misc queries) 1 August 23rd 06 08:16 PM
Shared Workbook [email protected] Excel Discussion (Misc queries) 0 July 27th 05 10:56 PM


All times are GMT +1. The time now is 07:22 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"