Waterpolo1
New Member
- Joined
- Sep 8, 2015
- Messages
- 21
Hi Team,
Please could someone help with the following issue.
Context
- I have a useform which requires the user to upload documents to the userform. I have it at the moment so the filepath is shown.
Question
What is the best way to allow for multiple documents to be selected and thus multiple file paths to populate an excel cell in a workbook?
Current method
To find the file:
Private Sub CommandButton2_Click()
'GetOpenFile MultiSelect will return an Array if more than one is selected
Dim FilePathArray As Variant
FilePathArray = Application.GetOpenFilename(, , , , MultiSelect:=True)
If IsArray(FilePathArray) Then
Dim ArraySize As Long
ArraySize = UBound(FilePathArray, 1) - LBound(FilePathArray, 1) + 1
Dim ArrayPosition As Long
For ArrayPosition = 1 To ArraySize
If Not FilePathArray(ArrayPosition) = Empty Then
UserForm.ComboBoxEvidence.AddItem (FilePathArray(ArrayPosition))
End If
Next ArrayPosition
ElseIf FilePathArray <> False Then
'userform name is "userform"
UserForm.ComboBoxEvidence.AddItem (FilePathArray)
End If
This populates files selected into a list but has the following issues:
1.) Doesn't allow the user to delete a file if they make a mistake
2.) You can only submit one excel file to a spreadsheet
Many thanks for your support.
Joseph
Please could someone help with the following issue.
Context
- I have a useform which requires the user to upload documents to the userform. I have it at the moment so the filepath is shown.
Question
What is the best way to allow for multiple documents to be selected and thus multiple file paths to populate an excel cell in a workbook?
Current method
To find the file:
Private Sub CommandButton2_Click()
'GetOpenFile MultiSelect will return an Array if more than one is selected
Dim FilePathArray As Variant
FilePathArray = Application.GetOpenFilename(, , , , MultiSelect:=True)
If IsArray(FilePathArray) Then
Dim ArraySize As Long
ArraySize = UBound(FilePathArray, 1) - LBound(FilePathArray, 1) + 1
Dim ArrayPosition As Long
For ArrayPosition = 1 To ArraySize
If Not FilePathArray(ArrayPosition) = Empty Then
UserForm.ComboBoxEvidence.AddItem (FilePathArray(ArrayPosition))
End If
Next ArrayPosition
ElseIf FilePathArray <> False Then
'userform name is "userform"
UserForm.ComboBoxEvidence.AddItem (FilePathArray)
End If
This populates files selected into a list but has the following issues:
1.) Doesn't allow the user to delete a file if they make a mistake
2.) You can only submit one excel file to a spreadsheet
Many thanks for your support.
Joseph