I believe these macros demonstrate what you need to know.
Demo1
outputs the paths and names of the workbooks open within the current copy of Excel.
In Demo2
, I test for a particular name and open it if it is not found. Note how I use the path of the workbook holding the macro. I normally keep related macro in the same folder so this can be convenient.
There may be a problem with "c:test.xls" although not quite the problem mentioned in the comment.
"c:test.xls" references the file "test.xls" within the current directory of drive C.
"c:\test.xls" references the file "test.xls" within the root directory of drive C.
Try Debug.Print CurDir
. You will probably get C:\Users\YourUserName\Documents
. Is this the location of "test.xls"
Option Explicit
Sub Demo1()
Dim InxWbk As Long
For InxWbk = 1 To Workbooks.Count
Debug.Print "Path=[" & Workbooks(InxWbk).Path & "] Name=[" & Workbooks(InxWbk).Name & "]"
Next
End Sub
Sub Demo2()
Dim Found As Boolean
Dim InxWbk As Long
Dim MasterList As Workbook
Found = False
For InxWbk = 1 To Workbooks.Count
If Workbooks(InxWbk).Name = "Fruit.xls" Then
Set MasterList = Workbooks(InxWbk)
Found = True
Exit For
End If
Next
If Not Found Then
Set MasterList = Workbooks.Open(ThisWorkbook.Path & "\Fruit.xls")
End If
Call Demo1
End Sub