Application.filesearch Replacement For Office 2007 - Excel Help & Excel Macro Help
SEARCH ENTIRE SITE LOADING..

OZGRID Excel Help & Excel Best Practices Forums

Information Helpful? Why Not Donate.

SPECIALS PAGE FOR BARGAINS | BUILD YOUR GOLF SWING | FREE CUSTOM FUNCTIONS ADD-IN


Download Active Data For Excel Demo


Go Back Excel Help & Excel Macro Help > HELP FORUMS > EXCEL HELP
HOME Register Forum Help Calendar Search For Today's Posts Mark Forums Read

Reply

Application.filesearch Replacement For Office 2007

ANSWERS TO SIMILAR QUESTIONS
Convert 2003 Macro To 2007 - Application.filesearchApplication.FileSearch Not Returning Results On Some Pre 2007 ComputersApplication.FileSearch Method in 2007Application.filesearchApplication.filesearch In Office 2007



Javascript DHTML Drop Down Menu Powered by dhtml-menu-builder.com

Create Excel dashboards quickly with Plug-N-Play reports.


 
Thread Tools Search this Thread
Old June 21st, 2007
Intelligent Converters
FREE DOWNLOADS
File/Password Recovery
jolivanes jolivanes is offline
Senior Member
 
I'm a Spammer:
MS Office Version: 2003 and 2007
Op System: Windows XP
Assumed Experience: Average
Join Date: 8th July 2004
English is 1st Language: No
Posts: 213 -- Threads: 38
Application.filesearch Replacement For Office 2007

In the following thread, richphillips wonders about Application.Filesearch

Application.filesearch In Office 2007

There was no answer to his question.

Is there a replacement for this? I have several macros that use Application.Filesearch
and I would like it to work not only with Excel 2003 but also with Excel 2007.

This is the function

VB: AutoLinked keywords will cause extra spaces before keywords. Extra spacing is NOT transferred when copy/pasting, but IS if the keyword uses "quotes".
Function CreateFileList(FileFilter As String, _ IncludeSubFolder As Boolean) As Variant ' returns the full filename for files matching ' the filter criteria in the current folder Dim FileList() As String, FileCount As Long CreateFileList = "" Erase FileList If FileFilter = "" Then FileFilter = "*.*" ' all files Debug.Print CurDir strFolder = BrowseForFolderShell(, , , 0) If strFolder = "" Then MsgBox "You Cancelled" Exit Function End If With Application.FileSearch .NewSearch .LookIn = strFolder .fileName = FileFilter .SearchSubFolders = IncludeSubFolder .FileType = msoFileTypeAllFiles If .Execute(SortBy:=msoSortByFileName, _ SortOrder:=msoSortOrderAscending) = 0 Then Exit Function Redim FileList(.FoundFiles.Count) For FileCount = 1 To .FoundFiles.Count FileList(FileCount) = .FoundFiles(FileCount) Next FileCount .FileType = msoFileTypeExcelWorkbooks ' reset filetypes End With CreateFileList = FileList Erase FileList End Function

Thanks and regards.

John
Print [Post / Thread] Reply With Quote
Old June 24th, 2007
Intelligent Converters
FREE DOWNLOADS
File/Password Recovery
jolivanes jolivanes is offline
Senior Member
 
I'm a Spammer:
MS Office Version: 2003 and 2007
Op System: Windows XP
Assumed Experience: Average
Join Date: 8th July 2004
English is 1st Language: No
Posts: 213 -- Threads: 38
Re: Application.filesearch Replacement For Office 2007

After a few days it should be OK to BUMP.
Thanks
Print [Post / Thread] Reply With Quote
Old June 24th, 2007
Intelligent Converters
FREE DOWNLOADS
File/Password Recovery
royUK royUK is offline
Publishes Private Messages
 
I'm a Spammer: YES
MS Office Version:
Op System: Windows XP
Assumed Experience: Poor (know the very basics)
Join Date: 26th January 2003
English is 1st Language:
Location: Lincolnshire,UK
Posts: 12,877 -- Threads: 67
Re: Application.filesearch Replacement For Office 2007

See this

Last edited by royUK : June 24th, 2007 at 08:47.
Print [Post / Thread] Reply With Quote
Old June 24th, 2007
RichardSchollar's Avatar
RichardSchollar RichardSchollar is offline
Banned
 
I'm a Spammer: YES
MS Office Version:
Op System: Windows XP
Assumed Experience: Poor (know the very basics)
Join Date: 18th September 2005
English is 1st Language: Yes
Location: Hampshire, UK
Posts: 1,278 -- Threads: 1
Re: Application.filesearch Replacement For Office 2007

Hi John

Filesearch has indeed been removed but the (very) old Dir remains, so you can use this instead, an example of which follows:

VB: AutoLinked keywords will cause extra spaces before keywords. Extra spacing is NOT transferred when copy/pasting, but IS if the keyword uses "quotes".
Sub testit() myvar = FileList("C:\") For i = LBound(myvar) To UBound(myvar) Debug.Print myvar(i) Next End Sub Function FileList(fldr As String, Optional fltr As String = "*.*") As Variant Dim sTemp As String, sHldr As String If Right$(fldr, 1) <> "\" Then fldr = fldr & "\" sTemp = Dir(fldr & fltr) If sTemp = "" Then FileList = Split("No files found", "|") 'ensures an array is returned Exit Function End If Do sHldr = Dir If sHldr = "" Then Exit Do sTemp = sTemp & "|" & sHldr Loop FileList = Split(sTemp, "|") End Function

This doesn't search subfolders but that functionality could no doubt be introduced. In the current spec you have to pass in the filepath to search.

Richard

EDIT: amended function so Do Loop doesn't error

Last edited by RichardSchollar : June 24th, 2007 at 08:59.
Print [Post / Thread] Reply With Quote
Old June 24th, 2007
RichardSchollar's Avatar
RichardSchollar RichardSchollar is offline
Banned
 
I'm a Spammer: YES
MS Office Version:
Op System: Windows XP
Assumed Experience: Poor (know the very basics)
Join Date: 18th September 2005
English is 1st Language: Yes
Location: Hampshire, UK
Posts: 1,278 -- Threads: 1
Re: Application.filesearch Replacement For Office 2007

For some reason I can't seem to edit my last message. I have changed the return type if no files are found (it simplifies the code):

VB: AutoLinked keywords will cause extra spaces before keywords. Extra spacing is NOT transferred when copy/pasting, but IS if the keyword uses "quotes".
Sub testit() myvar = FileList("C:\Test3") If TypeName(myvar) <> "Boolean" Then For i = LBound(myvar) To UBound(myvar) Debug.Print myvar(i) Next Else MsgBox "No files found" End If End Sub Function FileList(fldr As String, Optional fltr As String = "*.*") As Variant Dim sTemp As String, sHldr As String If Right$(fldr, 1) <> "\" Then fldr = fldr & "\" sTemp = Dir(fldr & fltr) If sTemp = "" Then FileList = False Exit Function End If Do sHldr = Dir If sHldr = "" Then Exit Do sTemp = sTemp & "|" & sHldr Loop FileList = Split(sTemp, "|") End Function
Print [Post / Thread] Reply With Quote
Old June 25th, 2007
Intelligent Converters
FREE DOWNLOADS
File/Password Recovery
ByTheCringe2 ByTheCringe2 is offline
OzMVP
 
I'm a Spammer:
MS Office Version: 2000 English
Op System: Windows XP
Assumed Experience: Average (Know Many Formulas)
Join Date: 7th December 2005
English is 1st Language: Yes
Location: Hampshire, England
Posts: 4,901 -- Threads: 85
Re: Application.filesearch Replacement For Office 2007

You can edit your posts only for 1 hour after posting.
__________________
.
Print [Post / Thread] Reply With Quote
Old June 25th, 2007
RichardSchollar's Avatar
RichardSchollar RichardSchollar is offline
Banned
 
I'm a Spammer: YES
MS Office Version:
Op System: Windows XP
Assumed Experience: Poor (know the very basics)
Join Date: 18th September 2005
English is 1st Language: Yes
Location: Hampshire, UK
Posts: 1,278 -- Threads: 1
Re: Application.filesearch Replacement For Office 2007

Ah that would expalin it! Thanks BTC2
Print [Post / Thread] Reply With Quote
Old June 25th, 2007
Dave Hawley's Avatar
Dave Hawley Dave Hawley is offline
Administrator
 
I'm a Spammer: NO
MS Office Version: 2007 English
Op System: Windows Vista
Assumed Experience: Above Average
Join Date: 24th January 2003
English is 1st Language: Yes
Location: Australia
Posts: 49,882 -- Threads: 15169
Re: Application.filesearch Replacement For Office 2007

Not too sure that it has been "removed" or M$ stuffed up and forgot to add it. Perhaps it will be added back after fixing the gazillion other bugs?
Print [Post / Thread] Reply With Quote
Old June 26th, 2007
Intelligent Converters
FREE DOWNLOADS
File/Password Recovery
jolivanes jolivanes is offline
Senior Member
 
I'm a Spammer:
MS Office Version: 2003 and 2007
Op System: Windows XP
Assumed Experience: Average
Join Date: 8th July 2004
English is 1st Language: No
Posts: 213 -- Threads: 38
Re: Application.filesearch Replacement For Office 2007

Parsnip, Roy, ByTheCringe2 and Dave, thanks for replying.
I put the suggested replacement code in from both Parsnip and Roy but I can't get things to work. Due to my ignorance of VB I have to say. I have looked and tried to understand the suggested code but I can't see where I need to change/add things to make it work as the file does in Excel 2003. I neglected to add the Sheet1 code to my first thread entry.
This is it.

VB: AutoLinked keywords will cause extra spaces before keywords. Extra spacing is NOT transferred when copy/pasting, but IS if the keyword uses "quotes".
Private Sub CommandButton1_Click() Dim filenamelist() As Variant filenameslist = CreateFileList("*.*", False) If Not IsArray(filenameslist) Then MsgBox "No files" Exit Sub End If For i = 1 To UBound(filenameslist) ActiveSheet. Cells(10 + i, 1).Value = filenameslist(i) Next i End Sub

I don't even know if you need it for the replies.

I have put Parsnip's and Roy's code in but because of my very limited VB knowledge, can't get it to work.
With Parsnip's code, I get either 'No files found" or nothing happens at all, depending on the changes I make.

In Roy's code it says "do something" but I don't even know what to enter at this point.

If someone has the time and would be willing to try the attached file in Excel 2003, he/she will see how it works and maybe tell me what to change where.

The code in the attached file is obviously not written by me.

Your help is greatly appreciated.

Thanks and regards.

John
Attached Files. REMINDER! OzGrid accepts no responsibility for ANY adverse effects as a result from downloading attached files. ALWAYS run an up-to-date virus scan and disable macros.
File Type: zip VB Print Filenames In Folder (For Music).zip (27.3 KB, 281 views)
Print [Post / Thread] Reply With Quote
Old June 26th, 2007
Dave Hawley's Avatar
Dave Hawley Dave Hawley is offline
Administrator
 
I'm a Spammer: NO
MS Office Version: 2007 English
Op System: Windows Vista
Assumed Experience: Above Average
Join Date: 24th January 2003
English is 1st Language: Yes
Location: Australia
Posts: 49,882 -- Threads: 15169
Re: Application.filesearch Replacement For Office 2007

Pasnips codes here works fine for me so long as I modify C:\Test3 to an extisting path on my PC.
Print [Post / Thread] Reply With Quote
Reply Lifetime Upgrade To Ad Free Styles

   « PREVIOUS Calculating Full-width Half-max (fwhm) || Inserting A Calendar Into A Spreadsheet NEXT »
Currently Active Users Viewing This Thread: 2 (0 members and 2 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT +9. The time now is 00:32.


Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Ozgrid is Not Associated With Microsoft. Ozgrid Retains the Rights to ALL Posts and Threads