Hopefully a stupid question, but it doesn't appear that way. Found an
example of a recursive file search, which is exactly what I want, at
Randy Birch's site (mvps.vbnet), but VBA is just different enough not
to compile.
Has anyone successfully adapted this to VBA? Any suggestions?
(Well, short of "go back to your village!")
thanks!
Pieter 8 13691 pi********@hotmail.com wrote: Hopefully a stupid question, but it doesn't appear that way. Found an example of a recursive file search, which is exactly what I want, at Randy Birch's site (mvps.vbnet), but VBA is just different enough not to compile.
Has anyone successfully adapted this to VBA? Any suggestions?
(Well, short of "go back to your village!")
thanks!
Pieter
There's more than 1 there, which one?
--
[OO=00=OO] pi********@hotmail.com wrote: Hopefully a stupid question, but it doesn't appear that way. Found an example of a recursive file search, which is exactly what I want, at Randy Birch's site (mvps.vbnet), but VBA is just different enough not to compile.
Has anyone successfully adapted this to VBA? Any suggestions?
(Well, short of "go back to your village!")
thanks!
Pieter
There's more than 1 there, which one?
--
[OO=00=OO]
You can adopt the following code that I used in ms-access.
Sub dirTest()
Dim dlist As New Collection
Dim startDir As String
Dim i As Integer
startDir = "C:\access\"
Call FillDir(startDir, dlist)
MsgBox "there are " & dlist.Count & " in the dir"
' lets printout the stuff into debug window for a test
For i = 1 To dlist.Count
Debug.Print dlist(i)
Next i
End Sub
Sub FillDir(startDir As String, dlist As Collection)
' build up a list of files, and then
' add add to this list, any additinal
' folders
Dim strTemp As String
Dim colFolders As New Collection
Dim vFolderName As Variant
strTemp = Dir(startDir)
Do While strTemp <> ""
dlist.Add startDir & strTemp
strTemp = Dir
Loop
' now build a list of additional folders
strTemp = Dir(startDir & "*.", vbDirectory)
Do While strTemp <> ""
If (strTemp <> ".") And (strTemp <> "..") Then
colFolders.Add strTemp
End If
strTemp = Dir
Loop
' now process each folder (recursion)
For Each vFolderName In colFolders
Call FillDir(startDir & vFolderName & "\", dlist)
Next vFolderName
End Sub
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada pl*****************@msn.com http://www.members.shaw.ca/AlbertKallal
You can adopt the following code that I used in ms-access.
Sub dirTest()
Dim dlist As New Collection
Dim startDir As String
Dim i As Integer
startDir = "C:\access\"
Call FillDir(startDir, dlist)
MsgBox "there are " & dlist.Count & " in the dir"
' lets printout the stuff into debug window for a test
For i = 1 To dlist.Count
Debug.Print dlist(i)
Next i
End Sub
Sub FillDir(startDir As String, dlist As Collection)
' build up a list of files, and then
' add add to this list, any additinal
' folders
Dim strTemp As String
Dim colFolders As New Collection
Dim vFolderName As Variant
strTemp = Dir(startDir)
Do While strTemp <> ""
dlist.Add startDir & strTemp
strTemp = Dir
Loop
' now build a list of additional folders
strTemp = Dir(startDir & "*.", vbDirectory)
Do While strTemp <> ""
If (strTemp <> ".") And (strTemp <> "..") Then
colFolders.Add strTemp
End If
strTemp = Dir
Loop
' now process each folder (recursion)
For Each vFolderName In colFolders
Call FillDir(startDir & vFolderName & "\", dlist)
Next vFolderName
End Sub
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada pl*****************@msn.com http://www.members.shaw.ca/AlbertKallal
Which one. Sorry, for some weird reason, I can't get the complete web
page address. but it's "Recursive File Search Demo - Multiple File
Types".
I got it to work. Except for the
List1.Clear
line. Apparently, VB6 and VBA are just ever so slightly different to
make porting the code really annoying. I stripped out all the
references to default properties, like .Text for textboxes and it
worked fine except for the List1.Clear. How to do that - I'm not sure
I'm that worried. Maybe set the thing's rowsource to nothing and
requery it... other than that, it seems to be working. If anyone's
interested, I'll post the code. The changes are basically minor.
Remove all references to default properties, change the rowsource type
of the listbox to Value List and away you go.
Which one. Sorry, for some weird reason, I can't get the complete web
page address. but it's "Recursive File Search Demo - Multiple File
Types".
I got it to work. Except for the
List1.Clear
line. Apparently, VB6 and VBA are just ever so slightly different to
make porting the code really annoying. I stripped out all the
references to default properties, like .Text for textboxes and it
worked fine except for the List1.Clear. How to do that - I'm not sure
I'm that worried. Maybe set the thing's rowsource to nothing and
requery it... other than that, it seems to be working. If anyone's
interested, I'll post the code. The changes are basically minor.
Remove all references to default properties, change the rowsource type
of the listbox to Value List and away you go. pi********@hotmail.com wrote: Which one. Sorry, for some weird reason, I can't get the complete web page address. but it's "Recursive File Search Demo - Multiple File Types".
I got it to work. Except for the
List1.Clear
line. Apparently, VB6 and VBA are just ever so slightly different to make porting the code really annoying. I stripped out all the references to default properties, like .Text for textboxes and it worked fine except for the List1.Clear. How to do that - I'm not sure I'm that worried. Maybe set the thing's rowsource to nothing and requery it... other than that, it seems to be working. If anyone's interested, I'll post the code. The changes are basically minor. Remove all references to default properties, change the rowsource type of the listbox to Value List and away you go.
Yes, List1.Rowsource="", shouldn't need to requery as changing the
rowsource automatically does that.
--
[OO=00=OO] pi********@hotmail.com wrote: Which one. Sorry, for some weird reason, I can't get the complete web page address. but it's "Recursive File Search Demo - Multiple File Types".
I got it to work. Except for the
List1.Clear
line. Apparently, VB6 and VBA are just ever so slightly different to make porting the code really annoying. I stripped out all the references to default properties, like .Text for textboxes and it worked fine except for the List1.Clear. How to do that - I'm not sure I'm that worried. Maybe set the thing's rowsource to nothing and requery it... other than that, it seems to be working. If anyone's interested, I'll post the code. The changes are basically minor. Remove all references to default properties, change the rowsource type of the listbox to Value List and away you go.
Yes, List1.Rowsource="", shouldn't need to requery as changing the
rowsource automatically does that.
--
[OO=00=OO] This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: alanwo |
last post by:
For recursive search for files, like
http://support.microsoft.com/default.aspx?scid=KB;EN-US;306666, it may
lead to "out of stack" error if searching too many files, say millions
of files.
Do you...
|
by: Talin |
last post by:
I've been using generators to implement backtracking search for a while
now. Unfortunately, my code is large and complex enough (doing
unification on math expressions) that its hard to post a...
|
by: pietlinden |
last post by:
Hopefully a stupid question, but it doesn't appear that way. Found an
example of a recursive file search, which is exactly what I want, at
Randy Birch's site (mvps.vbnet), but VBA is just...
|
by: Ameen |
last post by:
I am very new to programming and VB.net, and I wrote the code below,
but it seem to go on an infinite loop. Please tell me what I am doing
wrong.
Private Sub search(ByVal indexstart)
Pos1 =...
|
by: Robertico |
last post by:
I'am new to php and have a question about a recursive file search.
I'd like to do a recursive search for jpg-files and add the filenames (full
path) to a mysql database.
I appreciate any help !
...
|
by: AsheeG87 |
last post by:
Hello Everyone!
I have a linked list and am trying to include a recursive search.
However, I am having trouble understanding how I would go about that.
I don't quite understand a recursive...
|
by: Lloyd Sheen |
last post by:
For all those who don't think that a recursive search of files in folders is
a good thing in the Microsoft.VisualBasic.FileIO.FileSystem namespace
listen to this.
I am reorg my mp3 collection. ...
|
by: Jean-Paul Calderone |
last post by:
On Wed, 16 Apr 2008 13:18:22 -0700 (PDT), skanemupp@yahoo.se wrote:
Function calls (recursive or otherwise) are more expensive than
for loops, so the version that replaces recursion with a loop...
|
by: Simon Brunning |
last post by:
2008/7/4 Gerhard Häring <gh@ghaering.de>:
glob's not recursive AFAIK. This recipe probably still works under
Pythion 3K, though:
...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |