Search code examples
ms-accessvbams-access-2010linked-tables

Detecting broken linked Excel Tables


I am looking how to detect if a table has a broken link or not without resorting to attempting to use the table and have my access db error out. I universally have found that every resource uses code similar to this:

If Len(TableName.Connect) > 0 Then ...

or something similar but in my db if a table/file had a previously working link it maintains it's last known good .connect even if the link is broken. So checking the .connect does not work. Am I missing something? Or better yet is there a different solution to checking for broken links?


Solution

  • As the first, you can parse the Connect property:

    FileName = Split(CurrentDb.TableDefs("LinkedExcelRange").Connect, "=")(1)
    ' FileName -> d:\path\yourexcelfile.xlsx
    

    and check if that exists.