I want to link several worksheets of a workbook as linked tables.
This is the vba-code I use, which don't work
Any suggestions are welcome
sub LinkExcel(strWo rkBook)
Dim appXLS as Excel.Applicati on
Dim wrk as Excel.Workbook
Dim sht as Excel.WorkSheet
Dim tdf as DAO.tableDef
Set appXLS = New Excel.Applicati on
Set wrb = xlApp.Workbooks .Open(strWorkbo ok)
For Each sht In wrb.Worksheets
Set tdf = CurrentDb.Creat eTableDef(sht.n ame)
tdf.Connect = "Excel 5.0;HDR=YES;IME X=2;DATABASE=" & strWorkbook
tdf.SourceTable Name = sht.name
CurrentDb.Table Defs.Append tdf
Next
CurrentDb.Table Defs.Refresh
Application.Ref reshDatabaseWin dow
This is the vba-code I use, which don't work
Any suggestions are welcome
sub LinkExcel(strWo rkBook)
Dim appXLS as Excel.Applicati on
Dim wrk as Excel.Workbook
Dim sht as Excel.WorkSheet
Dim tdf as DAO.tableDef
Set appXLS = New Excel.Applicati on
Set wrb = xlApp.Workbooks .Open(strWorkbo ok)
For Each sht In wrb.Worksheets
Set tdf = CurrentDb.Creat eTableDef(sht.n ame)
tdf.Connect = "Excel 5.0;HDR=YES;IME X=2;DATABASE=" & strWorkbook
tdf.SourceTable Name = sht.name
CurrentDb.Table Defs.Append tdf
Next
CurrentDb.Table Defs.Refresh
Application.Ref reshDatabaseWin dow
Comment