I'm writing a microsoft word macro and having difficulty with vb.net. Please help.
Asked
Active
Viewed 2.1k times
4
-
[This](https://stackoverflow.com/a/730510/11738627) is the best solution, much faster than using FSO – 6diegodiego9 Sep 20 '22 at 08:53
3 Answers
4
Check out the answers here - VB6 is almost identical to VBA.
-
so what you're saying is this is that this question is a duplicate of others on this site, only the others have answers... – ashleedawg May 31 '19 at 07:42
-
No that's not what I'm saying. This question is about VBA. The answers to the other questions are for VB6 and cannot all be used directly in VBA. For instance *"You will need to add a reference to the Microsoft Scripting Runtime if you want to use `FileSystemObject`"* – MarkJ May 31 '19 at 11:08
2
A Word Macro is usually written in VBA rather than VB.Net, I'm assuming that you meant VBA?
Use the FileSystemObject
to access the filesystem and then use recursion to "walk" down. Here's a sample:
If it's actually VB.Net you're using, the idea will be the same but use System.IO.Directory
rather than the FileSystemObject
.

Hans Olsson
- 54,199
- 15
- 94
- 116
0
I personally like the FileSystemObject approach. i normally set up a recursive search function like the one found here and have never had any problems.

user2780436
- 583
- 5
- 9