Comparing file structures

Is there a way to compare the structure of a file, e.g. Excel file that you are going to import into an Access table before you actually do the import?  If the order of the columns or the column names in the spreadsheet do not match that of the table, Access will issue a warning and abort the procedure. I would like a more "elegant" way of dealing with it, i.e., being able to determine any discrepancy beforehand and not allow the user to proceed before that happens.
geeta_m9Asked:
Who is Participating?
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Connect With a Mentor Infotrakker SoftwareCommented:
You'd need to open the Excel workbook through automation and examine the structure, and make your determination from there.

Here's a good example on automating Excel:

http://access.mvps.org/access/modules/mdl0006.htm

In the code at the link above, you could expand on that to review the structure. For example:

    With objActiveWkb
        If .Worksheets(1).Cells(1, 1) = "SomeValue" Then
           Msgbox "Problem found in workbook"        
    End With
0
 
geeta_m9Author Commented:
So, I should put this code in a module in Access?
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Basically, yes. You'd add code like that to your Access application and run that code before you did the import. Obviously you'd have to flesh it out quite a bit to accurately review your structures and such.
0
 
geeta_m9Author Commented:
Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.