![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
![]() |

|
![]() |
|
Import Excel file to Access Table
|
LinkBack | Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Fixed Error!
Posts: 4,202
Join Date: Mar 2007
Rep Power: 6
IM:
|
I know I can use the DoCmd.TransferSpreadsheet but how do I import each sheet and only the columns that I need? The number of sheets each time could change. This is for Access 2000 DB. |
|
|
|
|
|
|
|
|
#2 (permalink) |
|
Fixed Error!
Posts: 4,202
Join Date: Mar 2007
Rep Power: 6
IM:
|
Dim xlAPP as Excel.Application Dim xlWkb as Excel.Workbook Dim xlWks as Excel.Worksheet Dim strSheets as String Dim varSheets as Variant Dim intSheet as integer Set xlApp = New Excel.Application Set xlWkb = xlApp.Open(Filename:="Full Path of your excel file goes here") For each xlWks In xlWkb strSheets = strSheets & xlWks.Name & ";" Next xlWkb.Close 'close down workbook Set xlWkb = Nothing xlApp.quit Set xlApp = Nothing 'Close down Excel Object strSheets = Left(strSheets,Len(strSheets)-1) varSheets = Split(strSheets,";") 'Place sheet names in variant array For intSheet = 0 to Ubound(varSheets) 'This for loop will iterate through each sheet name ' do stufff with varSheets(intSheet) Next |
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|