如何在vba中删除对象所需的错误

时间:2016-10-13 11:04:59

标签: vba

Sub Import_multiple_csv_files()
     'Modified from WillR - www.willr.info (December 2004)
     Dim vData As Variant

    Const strPath As String = "C:\Users\raman.yadav\Desktop\Inrush_data_files\" 'Directory Path
    Dim strFile As String 'Filename
    Dim strFileList() As String 'File  Array
    Dim intFile As Integer 'File Number

     'Loop through the folder & build file list
    strFile = Dir(strPath & "*.csv")
    While strFile <> ""
         'add files to the list
        intFile = intFile + 1
        ReDim Preserve strFileList(1 To intFile)
        strFileList(intFile) = strFile
        strFile = Dir()
    Wend
     'see if any files were found
    If intFile = 0 Then
        MsgBox "No files found"
        Exit Sub
    End If

    For intFile = 1 To UBound(strFileList)
      DoCmd.TransferText acImportDelimi, , _
        "Test", strPath & strFileList(intFile)

    Next

    MsgBox UBound(strFileList) & " Files were Imported"

End Sub

0 个答案:

没有答案