By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,732 Members | 1,660 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,732 IT Pros & Developers. It's quick & easy.


P: 31
Is there a way to differenciate between multiple Excel Spreasheets in an Excel Workbook when writing the code to TransferSpreadsheet?

When I do the command now, I only have one worksheet.

Expand|Select|Wrap|Line Numbers
  1. DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "Test", "c:/test.xls", True
Now suppose the workbook had 3 worksheets: "test1", "test2" and "test3". How would I name the file in the code if I only want to pull "test2"?

Thank you in advance for your input.
Feb 17 '09 #1
Share this Question
Share on Google+
6 Replies

Expert Mod 15k+
P: 31,662
I've moved this into the Answers forum for you. It had been posted in Insights.

On to your question :
Can you please clarify what you are trying to do. At one point you indicate you're reading FROM the spreadsheet, yet at another you indicate you're writing TO it :S
Feb 17 '09 #2

Expert Mod 15k+
P: 31,662
For importing a specific worksheet from your workbook file use the Range parameter :
Expand|Select|Wrap|Line Numbers
  1. DoCmd.TransferSpreadsheet TransferType:=acImport, _
  2.                           SpreadsheetType:=acSpreadsheetTypeExcel9, _
  3.                           TableName:="Test", _
  4.                           FileName:="c:/test.xls", _
  5.                           HasFieldNames:=True, _
  6.                           Range:="Test2!A1:Z999"
The Range parameter is in the standard Excel format for a range, but I don't know how to say simply load the available range within the sheet.
Feb 17 '09 #3

P: 31
Sorry......I am tring to do a transferspreadsheet from a workbook that has multiple worksheets. How do specify which worksheet I would like the code to pull?
Feb 17 '09 #4

Expert Mod 15k+
P: 31,662
When writing TO a range in a workbook, you need to ensure that the name of the table (or query) matches the name you choose for the worksheet.

Not always straightforward. Quite a limiting interface IMHO.
Feb 17 '09 #5

P: 31
Thank you very much. This helped me out a lot.
Feb 17 '09 #6

Expert Mod 15k+
P: 31,662
No worries. Very pleased to have helped :)
Feb 17 '09 #7

Post your reply

Sign in to post your reply or Sign up for a free account.