+ Reply to Thread
Results 1 to 11 of 11

How to check what users are in a Workbook on a shared drive?

  1. #1
    Registered User
    Join Date
    03-18-2007
    Location
    Port Washington, WI, USA
    MS-Off Ver
    2013
    Posts
    10

    Arrow How to check what users are in a Workbook on a shared drive?

    I've tried to use the following two portions of code to check what users are in an Excel 2010 workbook. In the first section of code, if I'm the only one in the workbook, it will return me as the user. However, when I'm the exclusive user and there are others in the workbook, the code returns me as the only person in the workbook. Also, when there are others in the workbook and I don't have exclusive access, when the code hits the, "Users = aDataWbk.UserStatus" section of code, I get the error: "Run time error '1004'. Cannot access the read-only document 'Z:\Reporting\IBE Scoreboard2.xlsm'.

    In the second section of code, I'm always returned as being the exclusive user of the workbook, regardless of how many people are in the workbook and who has exclusive access. Can anyone tell me what's going on? Please note, I posted this question yesterday morning in the Microsoft Answers forum and have gotten no responses. The link to that post is: http://answers.microsoft.com/en-us/o...a-d5eb2f5ec05d.

    Code section 1:

    Please Login or Register  to view this content.
    Code section 2:

    Please Login or Register  to view this content.
    Any help would be greatly appreciated!!

    Brian

  2. #2
    Registered User
    Join Date
    03-18-2007
    Location
    Port Washington, WI, USA
    MS-Off Ver
    2013
    Posts
    10

    Re: How to check what users are in a Workbook on a shared drive?

    Anyone? I've been struggling with this a lot. I thought that maybe I was calling the UserStatus array wrong, but I've tried a bunch of different things and can't get it to work.

    Brian

  3. #3
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: How to check what users are in a Workbook on a shared drive?

    Hi

    .UserStatus won't return users who have the file open as read-only. It will only return Exclusive and if the workbook is shared

    From MSDN

    The first element of the second dimension is the name of the user, the second element is the date and time when the user last opened the workbook, and the third element is a number indicating the type of list (1 indicates exclusive, and 2 indicates shared).

    The UserStatus property doesn't return information about users who have the specified workbook open as read-only.
    For your second part, have a look here, it has code for obtaining the exclusive user http://www.xcelfiles.com/IsFileOpen.html
    Last edited by Kyle123; 12-02-2011 at 11:13 AM.

  4. #4
    Registered User
    Join Date
    03-18-2007
    Location
    Port Washington, WI, USA
    MS-Off Ver
    2013
    Posts
    10

    Re: How to check what users are in a Workbook on a shared drive?

    Kyle,

    Thanks for your reply! I tried both the API and VBA versions and got the same results (shown below.) The "gobbledy-gook" that you see is what came up in the message boxes, it's not an error of the HTML that you're seeing. Any idea what's going on? I'm running Office 2010 on Windows XP Pro 2002 SP3.

    API Test Result:
    C:\Documents and Settings\btorrea\Desktop\IBE Scoreboard2.xlsm is already Open
    By 3c–$‹“ZOglNA`!9M1~ĘgŒ%*f*œD8‰_ƒS֍œ…$fM}>8?vŒˆbHs`€ '‹NQ 4?GNo:ju*mW~Z?vfǶNQ;r#sw›_=Mƒ~VӲZAz'ž‰G|‡^tfT-ѴId`F\v‡Y„ލ[g‘

    VBA Test Result:
    C:\Documents and Settings\btorrea\Desktop\IBE Scoreboard2.xlsm is already Open
    By 3c–$‹“ZOglNA`!9M1~ĘgŒ%*f*œD8‰_ƒS֍œ…$fM}>8?vŒˆbHs`€ '‹NQ 4?GNo:ju*mW~Z?vfǶNQ;r#sw›_=Mƒ~VӲZAz'ž‰G|‡^tfT-ѴId`F\v‡Y„ލ[g‘

    Brian

  5. #5
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: How to check what users are in a Workbook on a shared drive?

    In that case, I'm not sure I can help, this works fine for 2003 and I suspect is is to do with your Excel version. Unfortunately I only have '03 (which the code runs fine on) so I can't test 2010.

    What is the goal for this code? There may be a work around

  6. #6
    Registered User
    Join Date
    03-18-2007
    Location
    Port Washington, WI, USA
    MS-Off Ver
    2013
    Posts
    10

    Re: How to check what users are in a Workbook on a shared drive?

    Kyle,

    The goal of the code is just to find out who has read/write access to my data workbook. The reason that I need that information is so that when my manager logs-in to the charting notebook, she can know who has the read/write access to the data workbook. That way, if she needs to get read/write access, she knows who to call to tell them to get out of the data workbook.

    Brian

  7. #7
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: How to check what users are in a Workbook on a shared drive?

    Does this work for the exclusive user:
    Please Login or Register  to view this content.
    Last edited by romperstomper; 12-06-2011 at 12:25 PM.
    Remember what the dormouse said
    Feed your head

  8. #8
    Registered User
    Join Date
    03-18-2007
    Location
    Port Washington, WI, USA
    MS-Off Ver
    2013
    Posts
    10

    Re: How to check what users are in a Workbook on a shared drive?

    romperstomper,

    I get an 'invalid procedure call or argument, Run time error 5' at the following line when I run the code.
    Please Login or Register  to view this content.
    Brian

  9. #9
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: How to check what users are in a Workbook on a shared drive?

    What is the value of strfilename at the time?
    (note: I edited my initial post very shortly after posting as there was an error in the original code, so I hope you are using the right version)

  10. #10
    Registered User
    Join Date
    03-18-2007
    Location
    Port Washington, WI, USA
    MS-Off Ver
    2013
    Posts
    10

    Re: How to check what users are in a Workbook on a shared drive?

    strFileName = "Z:\Reporting\IBE Scoreboard2.xlsm"

    Brian

  11. #11
    Registered User
    Join Date
    02-20-2010
    Location
    Vancouver, BC
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    5

    Re: How to check what users are in a Workbook on a shared drive?

    I have a similar objective, but I use this code instead after some long research. HTH.

    Please Login or Register  to view this content.

    You have to make sure you have "Active DS Type Library" selected under "Tools" --> "References"

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1