PrivateFunction filelist(folderspec, Optional pstr = "*.txt") OnErrorGoTo errline Dim fs, f, f1, fc, i, farr Set fs = CreateObject("Scripting.FileSystemObject") Set f = fs.GetFolder(folderspec) Set fc = f.Files ReDim farr(1To fc.Count) ForEach f1 In fc If f1.Name Like pstr AndNot f1.Name Like"*~$*"Then i = i + 1 farr(i) = f1.Name EndIf Next ReDimPreserve farr(1To i) filelist = farr errline: EndFunction