Refreshing Table Links to Excel Programmatically

G

Guest

Hello,

I have quite a few excel workbooks that I am linking to in Access. Every
month, the location of these workbooks (linking to individual worksheets as
well) is going to change. How can I programmatically refresh these links so
I don't have to go in there one by one to refresh the location?

Thank you!
MN
 
T

Tim Ferguson

I have quite a few excel workbooks that I am linking to in Access.
Every month, the location of these workbooks (linking to individual
worksheets as well) is going to change. How can I programmatically
refresh these links so I don't have to go in there one by one to
refresh the location?



' create a handle to the linked table
Set db = CurrentDB()
Set tdf = db.Tabledefs("MyLinkedTable")

' make a new connection string using the correct path etc.
strConnect = _
"Excel 5.0;HDR=YES;IMEX=2;" & _
"DATABASE=M:\ThisWeeksData\GMDS_0to2.xls"

' put the string into the Connect property
tdf.Connect = strConnect

' tell Access to refresh the link and retreive the new data
tdf.RefreshLink




Hope that helps


Tim F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top