Issues with detecting open file

office has detected a problem with this file. to help protect your computer
how to tell who has a file open windows 10
list open files windows
microsoft word not opening files
powershell list open files
can't open word document windows 10
determine who has a file open on a network

I have literally copied and pasted and tested every bit of code from may BBs and the same thing happens with all of them. they all either tell me that that the file is open if it's open or closed or they tell me that the file is closed when it is open or closed. The code never gets it correct. Here is the last thing I tried and it was telling me it was not open when it was and when it wasn't

Can someone tell me if this is due to the file being located on the network

Sub Is_WorkBook_Open()

    Dim wBook As Workbook

    On Error Resume Next

    Set wBook = Workbooks("X:\Audit Tracking\Team_Larry\DailyReports\Larry_Blank.xlsm")

    'Not open

    If wBook Is Nothing Then

        MsgBox "Larry's Workbook is not open, Proceed to posting", vbCritical

        Set wBook = Nothing

        On Error GoTo 0

        'It is open

        MsgBox "Yes it is open, Notify Supervisor to close file", vbInformation

        Set wBook = Nothing

        On Error GoTo 0

    End If

End Sub

it was telling me it was not open when it was and when it wasn't

The Application.Workbooks collection contains all the workbooks opened in this instance of Excel.Application; if the workbook is opened by someone else on another machine, it's not in the collection and you can't use that method to know this.

If you're using the latest & greatest Excel 2016 on Office 365, see how you can dismiss that concern altogether using co-authoring features.

Otherwise, you can try sharing the workbook and then Excel can tell you exactly who has it opened, but then shared workbooks has a number of issues, including but not limited to, the inability to edit VBA code.

Using a hard-coded path is a good way to get false negatives, too. Open the file, verify its actual FullName and use that.

Dim i As Long
For i = 1 To Application.Workbooks.Count
    Debug.Print Application.Workbooks(i).FullName

If the file's location doesn't really matter, only its file name, you can iterate the opened files and see if one has a matching file name:

Dim i As Long
For i = 1 To Application.Workbooks.Count
    If Application.Workbooks(i).Name = "Larry_Blank.xlsm" Then
        MsgBox "File is opened."
        Exit For
    End If

OpenedFilesView - View opened/locked files in your system , Displays the list of all opened files on your system and allows you to close files for solving sharing violation problems. Next, you should be able to open this file without further problems. If you encountered this problem in many of your files, you may try the following steps: first, move these files into the same folder, open Word 2010, and then click " File ", and click " Options ".

When you open an Excel workbook a hidden temporary copy of the workbook will be created. This is presumably used to recovery crashed files. Notice that the temporary workbook's name and path is the same as the actual workbook but has ~$ prefixed to the filename. Since the file path remains the same, we can assume that the ↓`isWorkbookOpen()↓ will work even with mapped and shared folders.

Function isWorkbookOpen(Path As String) As Boolean
    Dim values() As String
    values = Split(Path, "\")
    values(UBound(values)) = "~$" & values(UBound(values))
    Path = Join(values, "\")

    isWorkbookOpen = Len(Dir(Path, vbHidden)) > 0
End Function

Office has detected a problem with this file, Open an embedded object; Perform a mail merge; Open a file from a viewer. In this situation, you receive the following error message: adoc Option 1. You can detect if a file is in use either by a WMI Query (if your OS is windows based) or by opening the file for write (Exception occurs when file is in use). Option 2. You could try to get a handle on the file, and see the which process has the ownership.

I believe your code will test if you have it open, on the computer your running the code from.

This code will open the workbook, if it opens in a read only state then someone else has it open. Note: If you open it on your computer, and then run this code on the same computer it will report that it's not in a read only state.

Sub Test()
Dim oWB As Workbook

Set oWB = Application.Workbooks.Open("C:\Temp\test.xlsx")      

If oWB.ReadOnly Then
    MsgBox "Open"
    MsgBox "Closed"
End If

End Sub

Excel, Word or PowerPoint file does not open because of file , Fixes issues in which you cannot open a Word, Excel or PowerPoint These problems occur when the association between the file and the  Several Windows users have been encountering the “Publisher has detected a problem in the file you are trying to open” whenever they try to open a file with Publisher. This happens with both files that were created in this Publisher program or obtained externally.

Twelve Tips to Cure Network File-Sharing Problems, Use these twelve easy tips to troubleshoot file-sharing problems and get Windows Can't open a shared folder or even see the computer on the network, or edit a or continue with more troubleshooting if it doesn't fix or detect the problem. Run the sfc /scannow command to check for issues with, and replace if necessary, important Windows files that may be corrupted or removed. System File Checker (the name of the tool run by executing the sfc command ) isn't a particularly likely solution to a post-Patch-Tuesday or other Windows update issue but it's the most logical next step if a System Restore doesn't do the trick.

Can't Open File Explorer. How To Fix It?, Firstly, to access these features, we need to open File Explorer. The guide below describes a number of methods to address this problem. It is recommended to run a free scan with Malwarebytes - a tool to detect malware and fix computer  2. Follow the New Simple Volume Wizard to specify volume size, assign drive letter and determine file system for the simple volume will be created. 3. Click “Finish” to close Wizard. Then you’ll be able to open the pen drive in File Explorer. Way 2. Update pen drive driver

I have trouble opening CSV files with Microsoft Excel. Is there a , The Comma and Semicolon Issue in Excel Due to Regional Settings for Europe. When opening standard CSV (Comma Separated Values) files in Excel you may​  Even in Safe Mode, the file would not open. In Publisher, I went to Options - Trust Center - Trust Center Settings. changed Add-Ins to Disable all Application Add-ins, tried to open the file, no change, set it back. changed Macro Settings to Enable All Macros, tried to open the file, no change, set it back. Any ideas?

  • You should avoid On Error Resume Next like the plague. Remove that, test it with every scenario and see what, if any, error is actually returned. Then trap for that specific error. Personally, I would also add code to make sure the file even exists at all.
  • removed the On Error Resume Next and received Runtime error '9' Subscript out of Range on this line
  • Set wBook = Workbooks("X:\Audit Tracking\Team_Larry\DailyReports\Larry_Blank.xlsm")
  • That's because Workbooks is interpreted as an undimensioned array. You're apparently not using the correct syntax to open a workbook.
  • @BillHileman Workbooks is an object collection, not an array. Error 9 is thrown when the specified file doesn't exist in the collection, which is exactly by design. OP isn't trying to open anything here.
  • The workbook does exist but when I copy and paste the code from above I'm still getting "Larry's workbook is not open" but it is
  • @rholdren is it opened on another computer? Take the time to read the top part of this answer.
  • copied and pasted about and entered the file is open and still tell me it's not
  • I have it open on my computer
  • Compare the path you're using to Debug.Print Workbooks(1).FullName (or Workbooks(2).FullName, depending on whether the file was opened first or second). If someone else has it opened on another machine, you will not be able to know. Excel will tell you.