"File In Use" Alert

JDaniluck

New Member
Joined
Feb 26, 2015
Messages
12
Hey All,

This is my first question on this site. I use it all of the time by searching through the forums. So I thought I would finally join in the fun. :)

Anyhow, time for business. I am running into a problem with the "File in Use" alert.

I am attempting to write a code to automatically write data to a workbook in a shared location.

Every now and then this workbook in this shared location is in use by another person.

I have written a code to keep trying to open up the workbook in "Write" mode. However, When my code runs I get the "File in Use" message. I would like to add code into my workbook to automatically select "Read-Only" if I am prompted by the "File in Use" message.

So my overall goal is to open up this workbook in "write" mode, but if it opens up in "Read-Only" then I have the workbook close and then start again in 30 seconds. This repeats until I am able to open the workbook in "Write."

Any thoughts on how to control the "File in Use" alert?

Here is my code so far -

Code:
Dim Myfile As Range
Dim NewFile As Variant
Dim WB1 As Workbooks
Dim RF As Worksheet

Set WB1 = Workbooks("Repair_Form.xlsm")
Set RF = WB1.Sheets("Repair_Form")

Set Myfile = RF.Range("AK4")
' Database Location

        Workbooks.Open (Myfile.Value)

    If Workbooks("Repair_Authorize_Database.xlsx").ReadOnly Then
        Workbooks("Repair_Authorize_Database.xlsx").Close
        CountDown_Timer.startCountDown
        Exit Sub
    Else
    
        MsgBox "I made it :)"
    End If
    
        Workbooks("Repair_Authorize_Database.xlsx").Save
        Workbooks("Repair_Authorize_Database.xlsx").Close
        
Exit Sub

ErrorHandle1:

    MsgBox "I can not determine if the file is in Read Only"
    Exit Sub

End Sub
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hey All,

To update everyone.

I tried using Workbooks.Open FileName:= Myfile.Value, Notify:=True & False. I still get this dang "File In Use" alert.
 
Upvote 0
File In Use Alert Message - VBA

Hello All,

A couple of days ago I posted a thread just like this and didn't get any answers.

http://www.mrexcel.com/forum/excel-questions/838881-file-use-alert.html

To sum up what I am trying to do is to simply control the "File In Use" alert message with VBA in excel 2010/2013.

I am trying to avoid using the Sendkey method. All I need is a way to select read-only if write is not available when openning a workbook.
 
Upvote 0
Re: File In Use Alert Message - VBA

Please just bump your original post - don't create duplicates. (I've merged the two).

Read only is the default option, so have you tried adding:
Code:
Application.DisplayAlerts = False
before opening the workbook?
 
Last edited:
Upvote 0
Re: File In Use Alert Message - VBA

You may have missed the edit to my post where I added a code suggestion.
 
Upvote 0
Re: File In Use Alert Message - VBA

Hey RoryA,

You are right, I did not see your edit.

I have tried this code and I still get the same result each time.

After the code loops for about the 3rd time I get the same alert message.
 
Upvote 0

Forum statistics

Threads
1,215,201
Messages
6,123,617
Members
449,109
Latest member
Sebas8956

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top