Results 1 to 4 of 4

Thread: iterating through .xls files in a folder - [RESOLVED]

Threaded View

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2002
    Posts
    586

    iterating through .xls files in a folder - [RESOLVED]

    Greetings,

    OK, I really appreciate eveyone's input here so far today. OK, now, I have a button on my VBA form, that when clicked should:

    1) Open a folder C:\FSR
    2) For each .xls file in that folder, go to "Tab 3" (which is the actual name of the third tab) and import external data to "tbl_Import_Temp", within the database being used, which is called "FinancialReports".

    Any idea the syntax for that? Here is what I have thus far:

    VB Code:
    1. Private Sub cmdStep1_Click()
    2.     Dim cnnConnection As ADODB.Connection
    3.     Dim rstImportTemp As ADODB.Recordset
    4.     'Dim Detail As String
    5.    
    6.     Set cnnConnection = CurrentProject.Connection
    7.    
    8.     Set rstImportTemp = New ADODB.Recordset
    9.     rstImportTemp.Open "tbl_Import_Temp", cnnConnection, adOpenStatic, adLockReadOnly, adCmdTable
    10.  
    11.     'open folder with Excel files
    12.     'for each file
    13.  
    14.         'Get External Data for tab 3 and put it into tbl_Import_Temp, using the first row as headers.
    15.     'next i
    16.    
    17.     MsgBox "Import of files, into the tbl_Import_Temp, is complete. Make sure the data looks OK; and then click the 'Step 2' button, below."
    18.      
    19.     rstImportTemp.Close
    20.     Set rstImportTemp = Nothing
    21.    
    22.     Set cnnConnection = Nothing
    23. End Sub

    Thank you,
    Jim
    Last edited by JimMuglia; Jul 22nd, 2005 at 10:38 AM. Reason: provide clarification, as well as to indicate resolution

Posting Permissions

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



Click Here to Expand Forum to Full Width