Importing Microsoft Word File Names

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a file in Microsoft Word that has over 5,000 Word Documents in it. I
want to copy only the filenames into an Excel Spreadsheet, so that I will
have a list of all of the documents in an Excel Spreadsheet. If anyone has
any guidance, it would be greatly appreciated.
 
Hi

Open the VB editor in Excel (F11 or similar).
Insert > Module.
Paste this into it:
'***************** start ***********************
Sub Test()
Call ListWordFiles("C:\Temp")
End Sub

Sub ListWordFiles(Folder As String)
Dim NextFile As String
Dim L As Long
On Error Resume Next

NextFile = Dir(Folder & "\*.do*")
Do Until NextFile = ""
L = L + 1
Cells(L, 1) = Folder & "\" & NextFile
ActiveSheet.Hyperlinks.Add _
anchor:=Cells(L, 1), _
Address:=Folder & "\" & NextFile
Cells(L, 2) = FileDateTime(Folder & "\" & NextFile)
NextFile = Dir()
Loop
End Sub
'********************* end *******************

Change the text "C:\Temp" to your real folder name. Return to Excel and run
the macro Test.

HTH. Best wishes Harald
 
Nothing Happened. Do I need to insert the ****start*** and ***end*** line as
well?
 
Those lines would make no difference. Please explain what you did and post
your "Test" macro.

Best wishes Harald
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top