Microsoft KB Archive/161336

= ACC: Cannot Import Spreadsheet If Field Name Begins with Space =

Article ID: 161336

Article Last Modified on 1/19/2007

-

APPLIES TO


 * Microsoft Access 95 Standard Edition
 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q161336



Moderate: Requires basic macro, coding, and interoperability skills.



SYMPTOMS
When you try to import a Microsoft Excel spreadsheet into a Microsoft Access database, you may receive the following error message:

An error occurred trying to import file ''. The file was not imported.



CAUSE
The error occurs if there is a space preceding one or more of the field names in the spreadsheet.



RESOLUTION
You can resolve the error in the following ways:


 * Open the spreadsheet in Microsoft Excel and remove the leading space from the field name.
 * Link the spreadsheet in Microsoft Access instead of importing it.



STATUS
Microsoft has confirmed this to be a problem in Microsoft Access 7.0 and 97.



Steps to Reproduce Problem
  Start Microsoft Excel and create the following spreadsheet. Type a space in front of the word "Cost":

     Item       Cost       Quantity a                  25              2 b                  23              8  Save the file as C:\My Documents\TestSpace.xls, and then quit Microsoft Excel. Start Microsoft Access and open the sample database Northwind.mdb. On the File menu, point to Get External Data, and then click Import.</li> In the Import dialog box, select Microsoft Excel (*.xls) in the Files Of Type box, and then select TestSpace.xls. Click Import.</li> Click Next in the first dialog box of the Import Spreadsheet Wizard.</li> In the "Does the first row specified contain column headings?" dialog box, click "First Row Contains Column Headings," and then click Finish. Note that you receive the error message.

To resolve the error, open TestSpace.xls in Microsoft Excel and remove the space in front of the word "Cost." Then repeat steps 2-7 and note that the error does not occur.</li></ol>

<div class="references_section">