Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exporting excel sheets

Status
Not open for further replies.

ziwacky

Programmer
Jun 27, 2000
43
US
I'm trying to automate an import from an excel worksheet and got to the following. You know when you use the import wizard for an excel workbook, that if you have more than one worksheet on your file it gives you the option to select which worksheet is the one you want to use. Cool. That is the exact logic I want, but in code. So far, I haven't seen anything that will allow me to select my worksheet. This is what I'm using for the import:

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel97, "MyTable", "myfile.xls", True

If myfile.xls has three worksheets what is going to happen. Is it the first worksheet that comes thru or what.X-) Let's say I only want worksheet 2 for my import. How do I do that.s-)

Thank you,

Z
 
If you leave the range parameter blank then sheet1 will be imported. If you want to specify the sheet to be imported then in the range parameter enter the name of the sheet to import from followed by an exclamation point.

example:


DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel97, "MyTable", "myfile.xls", True, "Sheet2!"


This should accomplish what you are wanting to do.

:)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top