I'm new to VBA so I'm not pretty sure what I'm doing. Please be kind.
What I'm trying to implement is, user select the files from File Picker and put the selected files' path into ArrayList. I created fileList as global variable then initialize it in Workbook_Open event.
I'm getting <code>Object variable or With block variable not set</code> error in adding String into the ArrayList.
What I'm trying to implement is, user select the files from File Picker and put the selected files' path into ArrayList. I created fileList as global variable then initialize it in Workbook_Open event.
I'm getting <code>Object variable or With block variable not set</code> error in adding String into the ArrayList.
Code:
<code>Option Explicit Dim fileList As Object Sub Browse_Click() Dim fd As FileDialog Dim oFD As Variant Dim Filepathname As String Set fd = Application.FileDialog(msoFileDialogFilePicker) With fd .ButtonName = "Select" .AllowMultiSelect = True .Filters.Add "CSV Files", "*.csv", 1 .Title = "Choose CSV File" .InitialView = msoFileDialogViewDetails .Show For Each oFD In .SelectedItems Filepathname = oFD fileList.Add (Filepathname) // <~~~~~~~~~~~~~~~~~ ERROR HERE Next oFD Dim Str As Object For Each Str In fileList MsgBox Str Next Str End With End Sub Private Sub Workbook_Open() Set fileList = CreateObject("System.Collections.ArrayList") End Sub</code></pre><code>
</code>
Last edited: