Relink Excel Spread Sheet to Access (on Shared Drive)

jpstory

Board Regular
Joined
Dec 17, 2010
Messages
118
Hi All

I have the following code that relinks tables to Excel files.
It works when the Excel files are saved on my local machine but fails if the files are on shared drive (a mapped drive).
Is there any work around to get it work on shared drive? Thanks !

Code:
Sub Test()
Dim db As Database
Dim tbl As TableDef
Dim MyTbl As DAO.TableDef
Dim Path As String

Set db = CurrentDb

For Each tbl In db.TableDefs
  If tbl.Name = "TblA" Then
    Set MyTbl = tbl
    MyTbl.Connect = "Excel 8.0;HDR=YES;IMEX=2;ACCDB=YES;DATABASE=C:\Test Folder\Testing\Test File A.xls[Sheet1$]"
    ' Fails if I Switch to Share Drive: MyTbl.Connect = "Excel 8.0;HDR=YES;IMEX=2;ACCDB=YES;DATABASE=T:\Test Folder\Testing\Test File A.xls[Sheet1$]"
    MyTbl.RefreshLink
    Exit Sub
  End If
Next
End Sub
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
1. Ensure that you don't have any access privilege issues with the mapped network server.
2. Use UNC (Universal Naming Conventions) for linking the table rather than the mapped drive.
3. change the link address:
T:\Test Folder\Testing\Test File A.xls[Sheet1$]
to \\ServerName\Test Folder\Testing\Test File A.xls[Sheet1$.

This method will allways ensure that the table is linked from the correct location from server and doesn't depend on the mapped drive letter.
 
Upvote 0

Forum statistics

Threads
1,215,341
Messages
6,124,391
Members
449,155
Latest member
ravioli44

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