Results 1 to 4 of 4
  1. #1
    rmceu1 is offline Novice
    Windows 10 Office 365
    Join Date
    Aug 2021
    Posts
    5

    Link to Excel Files with No Header

    I'm developing a database that requires data from many, massive Excel files that contain no header records. I need to link to these files, but I need meaningful field names rather than F1, F2,...F193. For various reasons, I do not want to import the data, and I'm not allowed to edit the source files to insert a header row.

    For reasons I can't fathom, Access doesn't allow creation and storage of a link specification as it does for import specs. So my initial solution was to programmatically rename the fields after successfully linking to the file, using a table of stored field names...

    Dim tdf as TableDef
    Dim fld as Field

    Set tdf = CurrentDB.TableDefs("LinkedExcelTable")
    For each fld in tdf.Fields


    fld.Name = DLookup("NewName", "tblFieldNames", "OldName = '" & fld.Name & "'")
    Next fld

    ...which works for normal tables, but throws the error "Operation not supported on a linked table". (Again, TableDef is stored internally within the database, so not sure why it can't be manipulated for a linked table, but that's a rant for another time).

    Anyway, any suggestions for a different approach to accomplish what I'm trying to do here?

  2. #2
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,001
    The easiest way to do it would be to create a query on the linked table that simply replaces f1 with an alias
    F1 as ProperField1Name , F2 as ProperField2Name etc.

    Then use the query everywhere instead of the table.
    It would be a pain to set up but only need doing once, and if you have the field names already quite simple to knock up in a text editor then dump into the SQL view if the query designer.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,861
    Create a temp table with your field names and union with linked Excel worksheet?

    You could have your own excel worksheets that just reference those other worksheets.?

    Duplicating I know, but it is one way?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    rmceu1 is offline Novice
    Windows 10 Office 365
    Join Date
    Aug 2021
    Posts
    5
    Thanks so much for your replies! Kicking myself for not thinking of Minty's query solution, which should give me just what I need.

    That said, I'll be interested to see any other creative solutions for this problem!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. link multiple excel files to one DB
    By Starchaser in forum Access
    Replies: 3
    Last Post: 06-13-2021, 03:14 PM
  2. Can I link 2 excel files into one Access table
    By Tibbs in forum Import/Export Data
    Replies: 3
    Last Post: 10-11-2017, 08:08 AM
  3. Replies: 4
    Last Post: 07-21-2017, 01:07 PM
  4. Replies: 0
    Last Post: 12-15-2014, 08:18 AM
  5. Replies: 1
    Last Post: 02-21-2011, 09:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums