Results 1 to 5 of 5

Thread: Import CSV Files Excel Multiple Select GetOpenFilename won't work argh!!!

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2013
    Posts
    3

    Exclamation Import CSV Files Excel Multiple Select GetOpenFilename won't work argh!!!

    Please please help me work out what is wrong with the below code. I simply want to select several files and process them into one worksheet in the same way; i recorded the processing, modified it to include and array in Y and put multiselect to true but it simply won't get past the GetOpenFilename part

    Code:
    Private Sub CommandButton1_Click()
           Dim X As Variant
    
           'Opens the dialog
           X = Application.GetOpenFilename("CSV Files (*.csv),*.csv,Text Files (*.txt),*.txt", 4, "Select Files", , True)
           
           
    
           'Loops through every file that is selected and opens each one
           For Y = 1 To UBound(X)
    
    With ActiveSheet.QueryTables.Add(Connection:= _
            "X(Y)", Destination _
            :=Range("1,(Y+(Y-1))"))
            .Name = "X(Y)"
            .FieldNames = True
            .RowNumbers = False
            .FillAdjacentFormulas = False
            .RefreshOnFileOpen = False
            .BackgroundQuery = True
            .RefreshStyle = xlInsertDeleteCells
            .SavePassword = False
            .SaveData = True
            .AdjustColumnWidth = True
            .TextFilePromptOnRefresh = False
            .TextFilePlatform = xlMacintosh
            .TextFileStartRow = 2
            .TextFileParseType = xlDelimited
            .TextFileTextQualifier = xlTextQualifierDoubleQuote
            .TextFileConsecutiveDelimiter = True
            .TextFileTabDelimiter = True
            .TextFileSemicolonDelimiter = False
            .TextFileCommaDelimiter = True
            .TextFileSpaceDelimiter = True
            .TextFileOtherDelimiter = """"
            .TextFileColumnDataTypes = Array(9, 5, 9, 1, 9, 9)
            .Refresh BackgroundQuery:=False
            .UseListObject = False
        End With
    
    Next Y
    
    End Sub
    
    Private Sub UserForm_Click()
    
    End Sub
    Last edited by Siddharth Rout; May 7th, 2013 at 08:53 AM. Reason: Added Code tags

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