View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein \(MVP - VB\)[_2390_] Rick Rothstein \(MVP - VB\)[_2390_] is offline
external usenet poster
 
Posts: 1
Default File Browse Function?

I really don't understand how that could be. I tested the code before
posting it, and I re-tested it just now, and it worked perfectly for me. All
I did was go to any code window (not the Immediate window though), type Sub
Test() and End Sub to give it someplace to work from and copy/paste'd the
code between them. When I run the Sub Test(), the file selector window
appeared... I used the Control Key to click-select a few files (although you
could only select one file if desired) and then clicked the Open button....
a MsgBox appeared for each file selected showing me its path and name. The
code works flawlessly for me... every time... so I am not sure what to tell
you. Is anyone else out there having trouble making the code I posted work?

Rick


"Stefi" wrote in message
...
Hi Rick,

I tried your code but it gave a "Type mismatch" error at line

For X = LBound(FilesToOpen) To UBound(FilesToOpen)

Locals window displayed the type of FilesToOpen to be Variant/String, not
an
array as it was expected.

Regards,
Stefi

€˛Rick Rothstein (MVP - VB)€¯ ezt Ć*rta:

Give this code a try...

Dim X As Long
Dim FilesToOpen As Variant
FilesToOpen = Application.GetOpenFilename(MultiSelect:=True)
For X = LBound(FilesToOpen) To UBound(FilesToOpen)
MsgBox "Selected File #" & X & ": " & FilesToOpen(X)
Next

Don't pick too many files as you should get a MsgBox for each one you
select.

Rick


"fallowfz" wrote in message
...
That's what I ran into as well. Thanks for giving it a shot.