How can I reference external books in VBA using a unique identifier that does not change when a file is opened? It works fine when the full path to the file is included, and the file with the same name is not open. However, when the file is open, the full form with the file track does not work and one file name does not work.
I wanted to create a Sub update to update all links, and it lures if the spreadsheet is open (see paragraph 2 below).
Here are some reasons why I think it should be possible:
- It seems that in the manual link update menu there is only the name of the file to be referenced;
- Also, you cannot open two books with the same name, and thus, if you open the original link, cell links change from the file path (and this is what causes the problem.
This code that I currently have updCellRefis a link to the file path cell (where I just want to use the file name):
Sub updateValues(updCellRef)
updFilePath = ActiveWorkbook.Sheets("INPUTS").Range(updCellRef).Value
ActiveWorkbook.updateLink Name:=updFilePath, Type:=xlExcelLinks
End Sub
To clarify this problem, it occurred when I used the above function to update the values, however, when the original spreadsheet was opened, only its file name refers to it. When it is closed, the full path to the file refers to it.
I am using Excel Professional 2010 v14 with VBA v7.0
Note. I do not want to use any other software, including Power Query, since it cannot be installed without administrator rights.