Dialog box to select multiple files

jsolomon

Board Regular
Joined
Mar 25, 2005
Messages
109
Hi,
I am trying to assign user selected filename(s) to a variable. At the moment, I have the code:

Application.GetOpenFilename

Unfortunately, it only allows me to assign one filename to a variable. Does anybody know how I would open a dialog box that would allow me to choose multiple filenames?

Thanks,

Joe
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Have you tied setting the Multiselect Parameter to True?

expression.GetOpenFilename(FileFilter, FilterIndex, Title, ButtonText, MultiSelect)
expression Required. An expression that returns an Application object.

FileFilter Optional Variant. A string specifying file filtering criteria.

This string consists of pairs of file filter strings followed by the MS-DOS wildcard file filter specification, with each part and each pair separated by commas. Each separate pair is listed in the Files of type drop-down list box. For example, the following string specifies two file filters— text and addin: "Text Files (*.txt),*.txt,Add-In Files (*.xla),*.xla".

To use multiple MS-DOS wildcard expressions for a single file filter type, separate the wildcard expressions with semicolons; for example, "Visual Basic Files (*.bas; *.txt),*.bas;*.txt".

If omitted, this argument defaults to "All Files (*.*),*.*".

FilterIndex Optional Variant. Specifies the index numbers of the default file filtering criteria, from 1 to the number of filters specified in FileFilter. If this argument is omitted or greater than the number of filters present, the first file filter is used.

Title Optional Variant. Specifies the title of the dialog box. If this argument is omitted, the title is "Open."

ButtonText Optional Variant. Macintosh only.

MultiSelect Optional Variant. True to allow multiple file names to be selected. False to allow only one file name to be selected. The default value is False
 
Upvote 0
That worked, I didn't even know it was an attribute. I'm having trouble using it however. Whereas Application.getopenfilename returns a string, I'm not exactly sure what Application.GetOpenFilename(MultiSelect:=True) is returning or how to use it.

For example lets say I select:
C:\temp\1.xls
C:\temp\2.xls

I see the variable is set as a variant with two strings inside, however how would I loop through these files and do something to them? Is this what an array is? What I woujld ultimately like to do is assign all the filenames/paths (comma seperated) to a variable. Thanks for your help, as I'm still somewhat novice to programming.
 
Upvote 0

Forum statistics

Threads
1,214,566
Messages
6,120,262
Members
448,953
Latest member
Dutchie_1

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top