Results 1 to 11 of 11

"File In Use" Message - how can this be disabled?

Threaded View

  1. #1
    Registered User
    Join Date
    07-20-2016
    Location
    UK
    MS-Off Ver
    2010
    Posts
    11

    "File In Use" Message - how can this be disabled?

    From 1 specific excel file, I have a button which opens another excel file, however I only want it to open the other excel file if it is not already opened by someone else.

    The below code works really well, except that Excel displays a "File In Use" message which offers the user 3 options: "Readonly","Notify","Cancel".
    This message is displayed immediately after the Workbooks.Open command.
    I don't want the user to see that message, because my vba will make the decision for them.
    But how can I get excel to not show that message?

    Sub Check_if_open()
    Dim LogFile As Workbook
    Dim OpenAttempt As Long
    
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    
    ReadOnlyReOpen:
        Workbooks.Open Filename:="C:\Folder Location\File to open.xlsx"
        Windows("File to open.xlsx").Activate
        Set LogFile = ActiveWorkbook
        If LogFile.ReadOnly Then
            LogFile.Close
            Debug.Print OpenAttempt
            If OpenAttempt <= 5 Then
                OpenAttempt = OpenAttempt + 1
                GoTo ReadOnlyReOpen
                Else
                    MsgBox "Log File is opened by someone else. Please try again in a bit."
                    Application.ScreenUpdating = True
                    Application.DisplayAlerts = True
                    Exit Sub
            End If
        End If
    
    MsgBox "Log File is open."
    
    End Sub
    Last edited by seaside_escape; 07-22-2016 at 06:32 AM. Reason: Issue now solved

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Excel 2010 -- "Visual Basic" "Macros" and "Record Macro" all disabled.
    By NicholasL in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-07-2017, 06:11 AM
  2. Replies: 7
    Last Post: 11-14-2013, 04:25 PM
  3. MSoffice Outlook 2003 message to be saved in C dir with the file name "From" "Sent" "Sub"
    By shailendra0509 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-09-2012, 01:32 AM
  4. Transfert cell values from file "A" to file "B" skipping columns in file "B".
    By Sentrosi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-16-2009, 11:11 PM
  5. Replies: 1
    Last Post: 03-29-2006, 09:15 AM
  6. Replies: 2
    Last Post: 10-15-2005, 10:05 AM
  7. Replies: 0
    Last Post: 10-12-2005, 12:05 PM
  8. Replies: 1
    Last Post: 04-07-2005, 12:06 PM

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