Microsoft Knowledge Base Email Alertz

KBAlertz.com: If you try to use the Import Spreadsheet Wizard to import a Microsoft Excel worksheet into an existing Microsoft Access 97 table, you may receive the following error message:

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]

Search KbAlertz

Advanced Search

Webmasters
Put kbAlertz on your website.
[ Click Here for more! ]





ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
The ad says 3 - but KBAlertz referrals get
** SIX MONTHS FREE **


Bug Tracking Software
For bug tracking software or defect tracking software or issue tracking software, visit Axosoft.


Community Site



We Send hundreds of thousands of emails using ASP.NET Email



Expert Web Design & Graphic Design
Design44.com

ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
The ad says 3 - but KBAlertz referrals get
** SIX MONTHS FREE **




Mentioned In








Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks




Article ID: 237996 - Last Review: January 24, 2007 - Revision: 3.1

ACC97: Error Importing Excel Worksheet with Mismatched or No Column Headers into Existing Access Table

This article was previously published under Q237996
Moderate: Requires basic macro, coding, and interoperability skills.

SYMPTOMS

If you try to use the Import Spreadsheet Wizard to import a Microsoft Excel worksheet into an existing Microsoft Access 97 table, you may receive the following error message:
An error occurred trying to import file '<filename>'. The file was not imported.

CAUSE

You receive this error message if the worksheet does not have column headers, or if one or more column headers do not match the field names in the Access table.

RESOLUTION

Although the Import Spreadsheet Wizard in Access will not import an Excel worksheet with a mismatched column header or no column headers at all, you can use the following steps to create an append query to add the data from the Excel worksheet to the target Access table:
  1. Count the number of columns (N) in the Excel worksheet. Make sure that the data that you want to import from the Excel worksheet is defined as a named range.
  2. Create a new query in Access. Do not add any tables to the query.
  3. On the Query menu, click SQL View.
  4. Change the SQL statement to one of the following. Use the first example if you do not have column headings in the Excel worksheet. Use the second example if the column headings in the Excel worksheet do no match the field names in the Access table.
       INSERT INTO [<Dest. Table>] (<Table field names separated by commas>) 
       SELECT F1, F2, F3,...,FN
       FROM [EXCEL 8.0; HDR=NO; IMEX=2; 
       DATABASE=<Path to Excel file>;TABLE=<NamedRange>].<NamedRange>;
    					
    -or-
       INSERT INTO [<Dest. Table>] (<Table field names separated by commas>) 
       SELECT <Worksheet column names separated by commas>
       FROM [EXCEL 8.0; HDR=YES; IMEX=2; 
       DATABASE=<Path to Excel file>;TABLE=<NamedRange>].<NamedRange>;
    					
    NOTE: F1 to FN should continue out to the number of columns being imported. Also, the order of the fields in the destination table field list must match the order of the unnamed fields in Excel. Replace the text inside the angle brackets (<>) with information about your Excel worksheet and Access table. The "<" and the ">" should be removed as well.

  5. Run the query. The data in the Excel worksheet should now be imported into the Access table.

REFERENCES

For more information about append queries, click Contents and Index on the Help menu, click the Index tab in Access Help, type the following text
append queries, creating
and then double-click the selected text to go to the "what is an action query and when would you use one" topic. If you are unable to find the information you need, ask the Office Assistant.


For more information about naming ranges, click Contents and Index on the Help menu, click the Index tab in Excel Help, type the following text
naming, ranges
and then double-click the selected text to go to the "name cells in a workbook" topic. If you are unable to find the information you need, ask the Office Assistant.

APPLIES TO
  • Microsoft Access 97 Standard Edition
Keywords: 
kbprb KB237996
Retired KB ArticleRetired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate

Be the first to leave feedback, to help others about this knowledge base article.

(Optional) Name

(Optional) Public URL Or Email

Comments
No HTML -- Text Only Please