+ Reply to Thread
Results 1 to 2 of 2

One Drive Test If Open

  1. #1
    Registered User
    Join Date
    09-18-2012
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    24

    One Drive Test If Open

    Hi

    I have some excel vba which writes to a One Drive file. All is fine unless someone else already has the file open. One Drive then stops the system and asks me if I want to create a second file.

    How can I test is someone already has the file open?

    Or how can I get VAB to respond to the question?

    Many thanks

    Max

  2. #2
    Forum Contributor
    Join Date
    08-10-2016
    Location
    Pakistan
    MS-Off Ver
    365
    Posts
    242

    Re: One Drive Test If Open

    One way to test if someone else already has an Excel file open is to use the FileLen function in VBA. This function returns the size of a file in bytes. If the file is open by another user, the FileLen function will return 0.

    Here's an example of how you can use the FileLen function to check if an Excel file is open:
    Please Login or Register  to view this content.
    You can use this code in your VBA macro to check if the file is open before attempting to write to it. If the file is open, you can display a message to the user or take some other appropriate action.

    Keep in mind that the FileLen function only works if the file is located on the local machine. If the file is located on a network drive or in a cloud storage service like OneDrive, the FileLen function will not work. In these cases, you may need to use a different method to check if the file is open, such as trying to open the file in read-only mode and handling any errors that occur.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Test for file open from Command Button on userform - not displaying open already message
    By nigelog in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-02-2017, 09:45 AM
  2. [SOLVED] Test Hyperlinks to files on Network Drive
    By joe.cross in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-18-2016, 08:34 PM
  3. Copy open file from the shared drive
    By GEMINI528 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-24-2014, 01:15 PM
  4. Open File off Network Drive
    By njohnson003 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-06-2013, 12:58 PM
  5. [SOLVED] Open Network drive without mappping the drive
    By AravJ in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-05-2012, 03:14 AM
  6. Replies: 0
    Last Post: 07-12-2011, 11:30 AM
  7. [SOLVED] WINDOWS CANNOT OPEN THIS FILE IN A:\ DRIVE
    By Hils in forum Excel General
    Replies: 3
    Last Post: 01-10-2006, 10:30 AM

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