Results 1 to 4 of 4
  1. #1
    Willem is offline Novice
    Windows 10 Office 365
    Join Date
    Jun 2020
    Posts
    3

    Access gives Error when importing .xlsx file

    Hi all!

    I've been working on a database to convert an automatically generated report into a text file for further processing.
    It all works perfectly, except for the import.

    I download a file every day, which will have a different name every day (starts with 'report' and then seemingly random numbers, i can't find a logic in it). This file claims to be a .xls, but when opening/saving it shows as a html doc. I then use Save As, to save it as a static file name (i.e. Access.xlsx).
    When i select this file as import in Access, it works fine, and i save it as SavedImport, so i can set an AutoExec on it.

    However, if i download a new report, and save it under the same name (Access.xlsx) and try to run the AutoExec (or manually), i get an error:
    'OriginalFileNameOfDownloadedReport' is not a valid name. Make sure that it does not include invalid characters or punctuation and that it is not too long.

    It works correctly if i manually import it, and then even on the AutoExec, but once the file has been replaced with a new file (with the exact same static file name), it gives this error.
    It seems to want to refer to some kind of sub-name (the original name of the file), even though the import path is set to the static name.


    EDIT: i've also tried it with the same as .xls file, but it gave the same error.
    Attached the 2 excel files. the .xls is how i download it, and the .xlsx is the same but then save d as .xlsx. I tried attaching the Access database, but it gives an error (failed to upload).
    What the database does, is reformat the columns/rows from the excel into a text file for use in Word Mail Merger.
    Report.zip

    Anyone know what this could be?


    Thanks!
    Last edited by Willem; 06-09-2020 at 03:25 AM.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Provide code and sample file. Attach files to post. Follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Willem is offline Novice
    Windows 10 Office 365
    Join Date
    Jun 2020
    Posts
    3
    Hi, thanks. I've added the Excel files

  4. #4
    Willem is offline Novice
    Windows 10 Office 365
    Join Date
    Jun 2020
    Posts
    3
    Update.
    I've been able to find out the cause of the issue.
    It was due to the Sheet name of the file. As Access links to the specific sheet name, this needs to be static, rather than changing (each new report has a new name of the sheet).
    Thank you all!

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

Similar Threads

  1. Data Type Error when Importing .xlsx or .csv (Dates)
    By TheSQLWasBetter in forum Import/Export Data
    Replies: 4
    Last Post: 04-16-2018, 03:51 PM
  2. Replies: 6
    Last Post: 12-18-2017, 07:05 PM
  3. Error on importing Excel file into MS Access.
    By Lou_Reed in forum Access
    Replies: 1
    Last Post: 09-01-2017, 02:15 PM
  4. Error when Importing CSV file to Access 2007
    By narendrabr in forum Import/Export Data
    Replies: 5
    Last Post: 01-08-2013, 02:05 AM
  5. Open Excel .xlsx file from Access
    By Bigmix in forum Programming
    Replies: 6
    Last Post: 02-28-2012, 09:55 AM

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