![]() |
Acquiring filenames for multiple files with GetOpenFilename
Hello from Australia,
I am new to this Newsgroup and fairly new to Excel programming as well, but the opportunity to talk to such a newsgroup looks very hopeful indeed. My problem is in trying to obtain the names of a group of files and use them in a program. Using: fName = Application.GetOpenFilename("DAT files(*.dat), *.dat", 1, "Select DAT files", , False) the last parameter, "False", indicates a single selection and it is stored in "fName", which I can use in a statement such as: MsgBox "File(s): " & fName This works ok. What is the form of the statement for multiple files? i.e.: fName = Application.GetOpenFilename("DAT files(*.dat), *.dat", 1, "Select DAT files", , True) Last parameter is "True". Does "fName" have to be declared as an array of strings? How can I access all the filenames from this multiple selection? Thanks in advance for any help. John. |
Acquiring filenames for multiple files with GetOpenFilename
Hi John,
Good day, from Japan. :-) The argument for multiple files is as you wrote, TRUE. And regarding to a variable type, please declare fName As Variant. When you select multiple files, it can store the file names as an array. And you can judge, if the variable fName has value with "VarType" as follows. Code: -------------------- Sub Macro1() Dim fName As Variant Dim f As Variant fName = Application.GetOpenFilename("DAT files(*.dat),*.dat", 1, "Select DAT files", , True) If VarType(fName) = 11 Then Exit Sub For Each f In fName MsgBox Dir(f) Next End Sub -------------------- --- Message posted from http://www.ExcelForum.com/ |
All times are GMT +1. The time now is 11:56 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com