Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 151
Default Excel 2007 filesearch

Hi all,

I have a list box that is populated by code to show the contents of a folder.
I use the Application.Filesearch to populate the listbox with the name of
the files in the folder.

This worked fine in Excel 2003, but for some reason Excel 2007 spits it out
with an error message (can't remember what it is).

Basically, I need to populate a listbox with the files in a folder.

All help appreciated.

Libby x
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Excel 2007 filesearch



Actually Filesearch did not work all that well. It was removed from XL 2007.
You can use the "Dir" function or the ScriptingRuntime "FileSystemObject".
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"Libby"
wrote in message
Hi all,
I have a list box that is populated by code to show the contents of a folder.
I use the Application.Filesearch to populate the listbox with the name of
the files in the folder.
This worked fine in Excel 2003, but for some reason Excel 2007 spits it out
with an error message (can't remember what it is).

Basically, I need to populate a listbox with the files in a folder.
All help appreciated.
Libby x
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 256
Default Excel 2007 filesearch

There is no FileSearch in Excel 2007 (or other Office 2007 programs).

You can use Dir. Here's a function I use that returns an array of
files in a directory. If you set the second parameter to True, it
will return folder names also. Array comes back unsorted.

Public Function FileList(ByVal strPath As String, _
Optional includeFolders As Boolean = False)
As String()
Const iIncr As Long = 50

Dim strFileName As String
Dim strPath As String

Dim iSize As Long

Dim i As Long

Dim retVal() As String

iSize = iSize + iIncr
ReDim retVal(1 To iSize)

If Right$(strDir, 1) < "\" Then strDir = strDir & "\"

strFileName = Dir(strDir & "*.*", _
IIf(includeFolders, vbDirectory, vbNormal))
Do While Len(strFileName) < 0
If Left$(strFileName, 1) < "." Then
i = i + 1
If i iSize Then
iSize = iSize + iIncr
ReDim Preserve retVal(1 To iSize)
End If
retVal(i) = strFileName
End If
strFileName = Dir()
Loop

If i < iSize Then
ReDim Preserve retVal(1 To i)
End If

FileList = retVal
End Function



On Feb 7, 8:03 pm, "Jim Cone" wrote:
Actually Filesearch did not work all that well. It was removed from XL 2007.
You can use the "Dir" function or the ScriptingRuntime "FileSystemObject".
--
Jim Cone
San Francisco, USAhttp://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)

"Libby"
wrote in message
Hi all,
I have a list box that is populated by code to show the contents of a folder.
I use the Application.Filesearch to populate the listbox with the name of
the files in the folder.
This worked fine in Excel 2003, but for some reason Excel 2007 spits it out
with an error message (can't remember what it is).

Basically, I need to populate a listbox with the files in a folder.
All help appreciated.
Libby x


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 151
Default Excel 2007 filesearch

Many thanks

"ilia" wrote:

There is no FileSearch in Excel 2007 (or other Office 2007 programs).

You can use Dir. Here's a function I use that returns an array of
files in a directory. If you set the second parameter to True, it
will return folder names also. Array comes back unsorted.

Public Function FileList(ByVal strPath As String, _
Optional includeFolders As Boolean = False)
As String()
Const iIncr As Long = 50

Dim strFileName As String
Dim strPath As String

Dim iSize As Long

Dim i As Long

Dim retVal() As String

iSize = iSize + iIncr
ReDim retVal(1 To iSize)

If Right$(strDir, 1) < "\" Then strDir = strDir & "\"

strFileName = Dir(strDir & "*.*", _
IIf(includeFolders, vbDirectory, vbNormal))
Do While Len(strFileName) < 0
If Left$(strFileName, 1) < "." Then
i = i + 1
If i iSize Then
iSize = iSize + iIncr
ReDim Preserve retVal(1 To iSize)
End If
retVal(i) = strFileName
End If
strFileName = Dir()
Loop

If i < iSize Then
ReDim Preserve retVal(1 To i)
End If

FileList = retVal
End Function



On Feb 7, 8:03 pm, "Jim Cone" wrote:
Actually Filesearch did not work all that well. It was removed from XL 2007.
You can use the "Dir" function or the ScriptingRuntime "FileSystemObject".
--
Jim Cone
San Francisco, USAhttp://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)

"Libby"
wrote in message
Hi all,
I have a list box that is populated by code to show the contents of a folder.
I use the Application.Filesearch to populate the listbox with the name of
the files in the folder.
This worked fine in Excel 2003, but for some reason Excel 2007 spits it out
with an error message (can't remember what it is).

Basically, I need to populate a listbox with the files in a folder.
All help appreciated.
Libby x



Reply
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
FileSearch Excel 2007 shaz Excel Discussion (Misc queries) 4 March 21st 10 02:07 AM
Excel 2002 to 2007 Macro containing "Filesearch" dede Setting up and Configuration of Excel 3 December 4th 09 05:00 PM
Application.FileSearch in 2007 Amery Excel Programming 2 December 13th 07 10:49 PM
replacement for filesearch in excel 2007 LWhite Excel Programming 1 September 10th 07 03:35 PM
replacement for Application.FileSearch in 2007 SteveDB1 Excel Programming 1 July 11th 07 06:28 PM


All times are GMT +1. The time now is 04:09 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"