locked
Macro Import Txt - Object not found - skip to next action RRS feed

  • Question

  • A form containing a button that allows users to import several Text files at the same time (required by users). I created an "Import macro" with following actions:

    DeleteObject: (Table - imported file)

    ImportExportText: (Import Delimited, Import Specification, Table, File name -path-, Has Field Names - Yes

    OpenQuery: Clearing query for null spaces and repeated row headers.  

    However, sometimes some of the files are not required and/or are not available in the path. I would like to find a way or a combination of actions in my "Import macro", that will substitute the not required or not available files into empty tables in the Access database, and will import all those that are available in the path. Based on what I have, what can I do? I'm not familiar with VSB, I work with queries and macro design options.


    • Edited by AlenaV Tuesday, November 24, 2020 2:35 PM
    Tuesday, November 24, 2020 2:33 PM

All replies

  • You are running up against the limitations of the macro language. I know of no way using macros to test if a file exists in a folder, or to iterate over the existing files in a folder.

    Maybe the best you can do in macros is somehow handle the error and keep going.

    This is why VBA exists: it is orders of magnitude more powerful than the macro language. If you don't want to learn it yourself, you may be able to pay someone to write it for you.


    -Tom. Microsoft Access MVP

    Tuesday, November 24, 2020 4:43 PM
  • Thank you Tom for your prompt answer.
    Tuesday, November 24, 2020 5:09 PM