Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to handle more then 1 file with GetOpenFilename

Status
Not open for further replies.

Johnomill

Technical User
Dec 19, 2001
19
NL
How can I access each File with Application.GetOpenFilename in Excel? I know the option Multiselect must by set to True.

My old VBA code was:
objA = Application.GetOpenFilename
A contains the path and filename
I call another macro and pass through the value of A

Now I want to do the same for a group of selected files. If objB contains the selection. How can I determine A for each file in the selection??
 
If MultiSelect=true, the GetOpenFileName method will return an array of filenames if the user selected at least one (i.e., didn't hit cancel). So you need to assign the return value of the method to a Variant, and check using the IsArray() function whether at least one filename was returned.

Example:

dim FNm as variant, i as integer
FNm = application.getopenfilename(multiselect:=true)
if IsArray(FNm) then
for i=1 to ubound(FNm)
.... use FNm(i) here ...
next i
else
.... handle the cancel event ....
endif

Rob
 
Thanks! It's just like Xi, It works deliciously
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top