Vb code to link tables to Excel

H

Hcoms

Hello,

I want to use vb code to mimick the "get external data" -> Link tables ->
Excel sheet .
I have a number of excel sheets within a number of excel workbooks and i
would like to automate this process. Any ideas on the code to link excel
docs to an access database? I am using access 2000

Cheers
 
S

Steve

Use the TransferSpreadsheet command;

DoCmd.TransferSpreadsheet acLink,
acSpreadsheetTypeExcel97, "**TABLE
NAME**", "**FILENAME**", True

Replace **TABLE NAME** and **FILENAME** with the table
name for the Link and Filename for the spreadsheet.

The True at the end denotes wether the spreadsheets have
Column names or not....

Steve.
 
H

Hcoms

Thanks for the quick response! I have now figured out thanks to your help
how to import a sheet e.g. Jan04! , How can import just column B in sheet
Jan04?

Cheers
 
S

Steve

You will need to give Column B a range name on your
spreadsheet.

Then in the TransferSpreadsheet command, specify the range
name after Spreadsheet has column names;

DoCmd.TransferSpreadsheet acLink,
acSpreadsheetTypeExcel97, "**TABLE
NAME**", "**FILENAME**", True, "**RANGE NAME**"
 
H

Hcoms

Cheers , i actual figured this one out by doing the following:
Sheetname!B:B
as the range
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top