473,396 Members | 1,840 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Excel Import - the second worksheet can't be found

Hello, everyone!

I need to import an Excel table consisting of two worksheets named 'ISKosten' and 'ITKosten'. The first worksheet is imported flawlessly.

However, Access doesn't seem to recognise the second sheet. After this piece of code:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, _
  2.                                             "IT", vrtSelectedItem, False, "ITKosten!A1:I80000"
I get error '3011': the Microsoft-Jet-Database modul couldn't find the object 'ITKosten$A1:I80000'.

WHY not? Everything works with the first worksheet!

Any help would be very much appreciated!

OfficeDummy
Jan 25 '08 #1
5 2765
Jim Doherty
897 Expert 512MB
Hello, everyone!

I need to import an Excel table consisting of two worksheets named 'ISKosten' and 'ITKosten'. The first worksheet is imported flawlessly.

However, Access doesn't seem to recognise the second sheet. After this piece of code:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, _
  2. "IT", vrtSelectedItem, False, "ITKosten!A1:I80000"
I get error '3011': the Microsoft-Jet-Database modul couldn't find the object 'ITKosten$A1:I80000'.

WHY not? Everything works with the first worksheet!

Any help would be very much appreciated!

OfficeDummy

leave the first sheet syntax as it is but put place a dollar sign in your syntax when you wish to import the second sheet you need two transferspreadsheet commands here remember one for the first sheet and any extra sheets need the dollar denotation for a sheet without the exclamation separator prior to the range

Expand|Select|Wrap|Line Numbers
  1. DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, _
  2. "IT", vrtSelectedItem, False, "ITKosten$A1:I80000"
Jim :)
Jan 26 '08 #2
leave the first sheet syntax as it is but put place a dollar sign in your syntax when you wish to import the second sheet you need two transferspreadsheet commands here remember one for the first sheet and any extra sheets need the dollar denotation for a sheet without the exclamation separator prior to the range

Expand|Select|Wrap|Line Numbers
  1. DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, _
  2. "IT", vrtSelectedItem, False, "ITKosten$A1:I80000"
Jim :)
Hi, Jim!

It still doesn't work. :( I get the same error. I tried changing the range to A1:I2000, but no success.

Any suggestions?
Jan 28 '08 #3
Jim Doherty
897 Expert 512MB
Hi, Jim!

It still doesn't work. :( I get the same error. I tried changing the range to A1:I2000, but no success.

Any suggestions?
ok this works 'flawlessly' on my machine amend the path to the xls file accordingly


Expand|Select|Wrap|Line Numbers
  1.  
  2. vrtSelectedItem = "D:\ITKosten.xls"
  3. DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, _
  4. "IT", vrtSelectedItem, False, "ITKosten!A1:I10"
  5. DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, _
  6. "IT", vrtSelectedItem, False, "ISKosten!A1:I10"
  7.  

Jim :)
Jan 28 '08 #4
ok this works 'flawlessly' on my machine amend the path to the xls file accordingly


Expand|Select|Wrap|Line Numbers
  1.  
  2. vrtSelectedItem = "D:\ITKosten.xls"
  3. DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, _
  4. "IT", vrtSelectedItem, False, "ITKosten!A1:I10"
  5. DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, _
  6. "IT", vrtSelectedItem, False, "ISKosten!A1:I10"
  7.  

Jim :)
But I thought vrtSelectedItem is already path direction, because I choose the Excel file from the FileDialog window. And I can't give a fixed path in the code because those tables are created weekly, and have therefore to be imported on a weekly basis...

Anyway, everything works miraculously now, even though I haven't changed a single thing neither in the code nor in the Excel map. (????)

It'd be still interesting to find out, what the problem was.

Best,
OfficeDummy
Jan 29 '08 #5
Jim Doherty
897 Expert 512MB
But I thought vrtSelectedItem is already path direction, because I choose the Excel file from the FileDialog window. And I can't give a fixed path in the code because those tables are created weekly, and have therefore to be imported on a weekly basis...

Anyway, everything works miraculously now, even though I haven't changed a single thing neither in the code nor in the Excel map. (????)

It'd be still interesting to find out, what the problem was.

Best,
OfficeDummy
Ask Bill Gates :)).. fact is vrtSelected item is a variable having an assigned value (and logically I agree with you) should contain the path to the relevant excel file whether this be hard coded or passed by the filedialog method, provided it identifies the file, this should be sufficient the only variances here are the actual targetted sheet within the file itself as required by the transferspreadsheet method

Regards

Jim :)
Jan 29 '08 #6

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

Similar topics

13
by: Allison Bailey | last post by:
Hi Folks, I'm a brand new Python programmer, so please point me in the right direction if this is not the best forum for this question.... I would like to open an existing MS Excel spreadsheet...
9
by: jillandgordon | last post by:
I am trying to import an excel file into Access 97. It looks perfectly all right but, every time I try to import it, I get to the lst step and am told that it was not imported due to an error. ...
0
by: optimizeit | last post by:
What I am attempting to do is import an Excel Workbook and display the worksheets in a datagrid dynamically. I am very close to getting this to work. I have to this point successfully imported a...
1
by: baling | last post by:
Hi.... Hi everybody, i have a code that i make in VBA and know I want to use this code in to VB6. But i don't know how to use that code in to VB 6.0 Please correct this code so i can use it in VB...
3
by: l2urhwhc4u | last post by:
Hello, I really need help with this problem I'm facing. I'm writing a recipe guide program using VBA form. I got to the part where the user can type in an ingredient and I need the program to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.