Ambiguous name detected error

frankT68

New Member
Joined
Jul 30, 2014
Messages
23
Office Version
  1. 365
Platform
  1. Windows
Hi!

I've been using the below piece of code successfully before

VBA Code:
 .
 .
 .

Dim myPath As String
 
    myPath = ThisWorkbook.Path & Application.PathSeparator 'Change path
   
      
        If IsFileOpen(myPath & "IzborQ.xlsx") = True Then

        MsgBox ("File is already opened")
        
        Else
            MsgBox ("File is not opened yet")
            Workbooks.Open (myPath & "IzborQ.xlsx")
        End If
.
.
.

VBA Code:
Function IsFileOpen(fileFullName As String)
    Dim FileNumber As Integer
    Dim errorNum As Integer

    On Error Resume Next
    FileNumber = FreeFile()   ' Assign a free file number.
    ' Attempt to open the file and lock it.
    Open fileFullName For Input Lock Read As #FileNumber
    Close FileNumber       ' Close the file.
    errorNum = Err         ' Assign the Error Number which occured
    On Error GoTo 0        ' Turn error checking on.
    ' Now Check and see which error occurred and based
    ' on that you can decide whether file is already
    ' open
    Select Case errorNum
        ' No error occurred so ErroNum is Zero (0)
        ' File is NOT already open by another user.
        Case 0
         IsFileOpen = False

        ' Error number for "Permission Denied." is 70
        ' File is already opened by another user.
        Case 70
            IsFileOpen = True

        ' For any other Error occurred
        Case Else
            Error errorNum
    End Select

End Function

However, when I ran the macro today, I got a warning saying: "Ambiguous name detected: IsFileOpen". I don't understand why, because I didn't change anything in the code.
Can someone please explain?
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
That error means you have two (or more) procedures with the same name.
You will need to delete, or the change the name, of one of them.
 
Upvote 0
Solution
Thank you for your reply, Fluff.
Indeed, I found a function with identical name (and change it). But I still don't understand why everithing had been working just fine until a few days ago:mad:. I have been using the same excel file for at least two years and during that time I have not changed the code, only the data on the sheets.
 
Upvote 0
I suspect that at some point somebody copied the function for some reason.
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

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