Link to home
Start Free TrialLog in
Avatar of rpreiss
rpreiss

asked on

Access VBA Import table

I have a macro that is currently in an Excel Module that reformats excel sheets so they are importable into access.  How would I write code in access that will run the procedures that are currently in the excel module to reorganize the tables, but also import them into seperate tables for each sheet in the workbook?

Thanks,

Artie
ASKER CERTIFIED SOLUTION
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rpreiss
rpreiss

ASKER

how do you use the transferspreadsheet method and the DoCmd.  Unfortunaetly I am very new to this, especially with Access.

Thanks,

Artie
Artie,

Go to the VB Editor, and do a search on TransferSpreadsheet in the Help.
eg below, replace names accordingly
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, "AccessTableName", "c:\excelfile.xls", True  'true for has field names

put it inside your loop through your worksheets etc
Avatar of rpreiss

ASKER

How would I construct this loop to go through all of the sheets in the workbook?  I am new to VBA.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Forced accept.

Computer101
EE Admin