LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default GetOpenFilaName

When the MultiSelect parameter is True, GetOpenFileName returns an
array, even if a single file is selected. First, test the result to
see if it is an array. If it is, then one or more files were selected.
If it is not an array, then the user cancelled the operation. For
example,


Dim FileNames As Variant
Dim N As Long
FileNames = Application.GetOpenFilename( _
filefilter:="Text Files (*.txt),*.txt", _
MultiSelect:=True)
If IsArray(FileNames) Then ' were files selected?
' loop through array of file names
For N = LBound(FileNames) To UBound(FileNames)
Cells(N, 1).Value = FileNames(N)
Next N
Else
' user cancelled the operation
Debug.Print "user cancellled"
End If

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)


On Mon, 9 Mar 2009 00:34:00 -0700, ???
wrote:

Hi all!

I am using the Application.GetOpenFilaName procedure in order the get the
path of files. if it is in a MultiSelect mode the pathes are an array. I
tried to copy them to a worksheet but i got only the last path. Is it posible
to get all the pathes each one in a separate cell?

FileName = Application.GetOpenFilename(FileFilter:="Text File
(*.txt),*.txt", MultiSelect:=True)
Range("A1").Value = FileName

Thanks in advance

Eli

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright 2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"