RawlinsCross
Active Member
- Joined
- Sep 9, 2016
- Messages
- 437
I would have thought that this should be fairly straight forward but I'm running into issues on opening additional workbooks from a userform. So yes, I have a userform with a button that when clicked opens up a number of additional workbooks.
Is this a problem with the string sent to "Workbooks.Open"
Is this a problem with the string sent to "Workbooks.Open"
Code:
Private Sub LoadSAP_Click()
Dim fd As Office.FileDialog
Dim strFile As String
Dim i As Integer
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.Filters.Clear
.Filters.Add "Excel Files", "*.xlsx?", 1
.Title = "Choose 2 Files"
.AllowMultiSelect = True
.InitialFileName = "C:\Users\Username\Desktop\VBA Projects\PM Monitoring\"
If .Show = True Then
For i = 1 To .SelectedItems.Count
strFile = Dir(.SelectedItems(i))
Workbooks.Open (strFile)
Next i
End If
End With
End Sub