Application.GetOpenFilename never returns a variant array

A

Alan

In Excel 2002 SP-2

I want to use the following well-known code to allow the user to select multiple files and then do something with them

Dim fName As Varian
Dim f As Varian

fName = Application.GetOpenFilename("Files(*.*),*.*", 1, "Select files", , True

For Each f In fNam
'Do something with
Nex

When I run this, however, the dialog works properly, but I get a type mismatch error (13) on the For statement. In the variable watch window
VarType(fName) returns 8 (String
IsArray(fName) returns Fals
LBound(fName) returns <Type mismatch
fName returns the last filename selected, with a type of Variant/Strin
 
J

Jonathan West

Hi Alan,

If you are using Office XP or later, then instead of using GetOpenFileName,
you can use the Application.FilePicker object to get multiple selected
files.

--
Regards
Jonathan West - Word MVP
http://www.multilinker.com
Please reply to the newsgroup


Alan said:
In Excel 2002 SP-2:

I want to use the following well-known code to allow the user to select
multiple files and then do something with them:
Dim fName As Variant
Dim f As Variant

fName = Application.GetOpenFilename("Files(*.*),*.*", 1, "Select files", , True)

For Each f In fName
'Do something with f
Next

When I run this, however, the dialog works properly, but I get a type
mismatch error (13) on the For statement. In the variable watch window:
 
A

Alan

If you are using Office XP or later, then instead of using GetOpenFileName,
you can use the Application.FilePicker object to get multiple selected
files.

I'm using XL2002.
 
J

Jonathan West

Alan said:
I'm using XL2002.

Sorry, I meant Application.FileDialog, (FilePicker is one of the dialogs you
can use), and it is available in XL2002
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top