+ Reply to Thread
Results 1 to 4 of 4

How can I see if another user has a workbook open and display an error message?

  1. #1
    Registered User
    Join Date
    01-26-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    2

    How can I see if another user has a workbook open and display an error message?

    Hi,

    I am a VBA novice, and putting code together based on what I find online, so any help is really appreciated!

    I want to open a document from the shared drive, make some changes to it, save it and close it again. That part I think I have managed, but what I need to do now is to test whether someone else already has it open, and if they do, then exit the macro and display a message. Otherwise it just opens in read only and saves as a copy, and I don't want that to happen.

    From looking around in this forum, it seems like I need to use something like:
    If Workbooks(PathToFile & "\" & NameOfFile).ReadOnly Then

    ...but I can't seem to make it work. Do I need to set this to be a variable?

    Thank you

  2. #2
    Forum Contributor
    Join Date
    06-16-2011
    Location
    London
    MS-Off Ver
    Excel XP
    Posts
    276

    Re: How can I see if another user has a workbook open and display an error message?

    You'll need a function and a function call:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    01-26-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: How can I see if another user has a workbook open and display an error message?

    Thanks so much - that works great!

    What is the last 'End' for under the MsgBox row?

    (actually don't worry, just solved that - it does the same as exit sub?)
    Last edited by messyjessyr; 01-27-2012 at 07:09 AM.

  4. #4
    Forum Contributor
    Join Date
    06-16-2011
    Location
    London
    MS-Off Ver
    Excel XP
    Posts
    276

    Re: How can I see if another user has a workbook open and display an error message?

    Exactly, it's not really necessary but I cut and paste that section of code from the middle of a macro in a very large project I'm writing.

    Don't forget to mark your thread as 'solved'.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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