ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Importing Microsoft Word File Names (https://www.excelbanter.com/excel-worksheet-functions/17790-importing-microsoft-word-file-names.html)

jrwaguespack

Importing Microsoft Word File Names
 
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.

Harald Staff

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

"jrwaguespack" skrev i melding
...
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.




jrwaguespack

Nothing Happened. Do I need to insert the ****start*** and ***end*** line as
well?

"Harald Staff" wrote:

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

"jrwaguespack" skrev i melding
...
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.





Harald Staff

Those lines would make no difference. Please explain what you did and post
your "Test" macro.

Best wishes Harald

"jrwaguespack" skrev i melding
...
Nothing Happened. Do I need to insert the ****start*** and ***end*** line

as
well?





All times are GMT +1. The time now is 07:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com