Hi all,
Hope you're having a good day.
I want to create a popup for a user to choose between three options
Select a file, Select a folder, Cancel
I made a userform to handle this.
If they choose to select the first option, I want to use Application.FileDialog(msoFileDialogFilePicker)
to load 1 - X file names into an array, then continue with each file from the array
If they choose the second option, I want to use Application.FileDialog(msoFileDialogFolderPicker)
to load the folder, then scan the folder etc etc.
I thought to create a userform with two buttons, each Goto SelectFile or Goto ChooseFolder, but in my searches people said its better to direct the button to a separate sub, than to the middle of a sub (via goto)
So I put my msoFileDialogs in different subs, but how can I move the array back to the main sub?
Thank you!!
Edit: The second sub works to load the array into the main, but I just need help with connecting this all with the userform
Private Sub SelectButton_Click()
Call SelectFiles(MyFiles)
Me.Hide
End Sub
It doesn't know what Myfiles is
So if I add Dim MyFiles() as String
it will work, but when I return back to the main sub, i'll get "expression not defined in context" <expression not="" defined="" in="" context=""> in the Watches</expression>
Hope you're having a good day.
I want to create a popup for a user to choose between three options
Select a file, Select a folder, Cancel
I made a userform to handle this.
If they choose to select the first option, I want to use Application.FileDialog(msoFileDialogFilePicker)
to load 1 - X file names into an array, then continue with each file from the array
If they choose the second option, I want to use Application.FileDialog(msoFileDialogFolderPicker)
to load the folder, then scan the folder etc etc.
I thought to create a userform with two buttons, each Goto SelectFile or Goto ChooseFolder, but in my searches people said its better to direct the button to a separate sub, than to the middle of a sub (via goto)
So I put my msoFileDialogs in different subs, but how can I move the array back to the main sub?
Thank you!!
Edit: The second sub works to load the array into the main, but I just need help with connecting this all with the userform
Private Sub SelectButton_Click()
Call SelectFiles(MyFiles)
Me.Hide
End Sub
It doesn't know what Myfiles is
So if I add Dim MyFiles() as String
it will work, but when I return back to the main sub, i'll get "expression not defined in context" <expression not="" defined="" in="" context=""> in the Watches</expression>
Last edited: