Results 1 to 6 of 6

Can't import files, should be simple code

Threaded View

  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).

    Sub Import_Files()
    
    Dim ws As Worksheet
    Dim ws1 As Worksheet
    Dim path1 As String
    Set ws = Worksheets("Main")
    Set ws1 = Worksheets("Lists")
    Set xl = CreateObject("Excel.Sheet")
    path1 = ws1.Range("B2").Value ' will be my development directory until put in use
    Application.ScreenUpdating = False
    
    CurrentFileName = Dir(path1 & "\*.xls")
    
    'H:\zz - working on it\CutSheet ' my development directory
    
    Do
        xl.Application.Workbooks.Open Dir(path1 & CurrentFileName)
        
        Sheets().Move after:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
    
        CurrentFileName = Dir()
    Loop While CurrentFileName <> ""
    
    
    End Sub
    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

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