|
|
Access 97: Help relinking Excel TablesQuestionI use Access to link -MANY- Excel spreadsheets. I've used the Add-In "Linked Table Manager" to change the directory that the sheets are stored in -but- it doesn't seem to let you change the name of the "sheet" it's linked to.. :-/ I would like to edit these using VBA(since they're are so many), if it's possible. AnswerChris, Here is an example: Dim dbs As Database
Dim tdef As TableDef
Dim strLink As String
Set dbs = CurrentDb()
' Delete old attachment
On Error Resume Next
dbs.TableDefs.Delete "Book1"
'Create new attachment
Set tdef = dbs.CreateTableDef("Book1")
strLink = "Excel 5.0;DATABASE=C:\Book1.xls;"
tdef.Connect = strLink
tdef.SourceTableName = "Sheet2$"
dbs.TableDefs.Append tdef
Copyright © 1999-2008 by Shamil Salakhetdinov. Original version is published here. All rights reserved. |