I am trying to select a bunch of files, using:
Set fd = Application.FileDialog(msoFileDialogFilePicker)
and then I have to process each one of the selected files (I allow multiple selection) and write it back into a destination directory. My problen is that when I use:
Set destFolder = Application.FileDialog(msoFileDialogFolderPicker)
to pick the destination folder, fd
gets overwritten, because the Application object only can instantiate a single FileDialog
object. And then I loose the SelectedItems
list from fd
.
How should I do it so I can keep the list for iteration?
Just save the SelectedItems list returned by fd.
Sub test()
Dim fd As FileDialog, destFolder As FileDialog
Dim s As FileDialogSelectedItems
Set fd = Application.FileDialog(msoFileDialogFilePicker)
fd.AllowMultiSelect = True
fd.Show
Set s = fd.SelectedItems ' s will be kept after next line
Set destFolder = Application.FileDialog(msoFileDialogFolderPicker)
End Sub