Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to list all files of a given folder (recursively through sub-folder)?

Tags:

ms-word

vba

I'm writing a microsoft word macro and having difficulty with vb.net. Please help.

like image 349
Nam G VU Avatar asked Oct 19 '25 09:10

Nam G VU


2 Answers

Check out the answers here - VB6 is almost identical to VBA.

  • You will need to add a reference to the Microsoft Scripting Runtime if you want to use FileSystemObject
  • Or you can just drop in the CDirDrill class which means you won't need any external references.
like image 69
MarkJ Avatar answered Oct 22 '25 03:10

MarkJ


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:

http://www.java2s.com/Code/VBA-Excel-Access-Word/File-Path/RecursiveSearchusingtheFileSystemObjectModel.htm

If it's actually VB.Net you're using, the idea will be the same but use System.IO.Directory rather than the FileSystemObject.

like image 28
Hans Olsson Avatar answered Oct 22 '25 03:10

Hans Olsson