+ Reply to Thread
Results 1 to 6 of 6

Can't import files, should be simple code

  1. #1
    Registered User
    Join Date
    12-20-2008
    Location
    Arkansas
    MS-Off Ver
    2010
    Posts
    87

    Can't import files, should be simple code

    I'm having trouble importing files. Here is just the import portion that I'm trying to build (that I can't make work).

    Please Login or Register  to view this content.
    I have all the files in place in the "dev" folder, but keep getting an error that the filename is not found.

    The file names that will be imported are:
    W14X99992.xls
    W14X99588.xls
    W14X99AHA.xls
    and so on...

    There may be as few as 2 files or as many as 20 files to include in this new workbook. They are not static names or I could simple name all the options, so I need a wildcard entry.

    Many thanks.
    Last edited by Obfuscated; 11-09-2012 at 03:00 PM. Reason: Solved

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Can't import files, should be simple code

    Try something like this...

    xl.Application.Workbooks.Open path1 & "\" & CurrentFileName

  3. #3
    Registered User
    Join Date
    12-20-2008
    Location
    Arkansas
    MS-Off Ver
    2010
    Posts
    87

    Re: Can't import files, should be simple code

    I've tried that also. Keep getting the same error.
    When I debug the lines, the path and file names are correct but I get the "File not found" error, check spelling, etc. messagebox.

    I've attached the workbook I've started. The files trying to be opened are single sheet books with no macros.
    Attached Files Attached Files

  4. #4
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Can't import files, should be simple code

    Obfuscated,

    Give this a try:
    Please Login or Register  to view this content.
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Can't import files, should be simple code

    Did you use exactly this?
    xl.Application.Workbooks.Open path1 & "\" & CurrentFileName


    Because that is not the same as this (from your code in the attached file) which uses the Dir function
    xl.Application.Workbooks.Open Dir(path1 & "\" & CurrentFileName)

    The Dir function only returns the file name which you already have in CurrentFileName

  6. #6
    Registered User
    Join Date
    12-20-2008
    Location
    Arkansas
    MS-Off Ver
    2010
    Posts
    87

    Cool Re: Can't import files, should be simple code

    Thanks guys for the help. You were right AlphaFrog, I did forget to change the "DIR" to "PATH1". It works great. Problem solved, onward to the next one.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1