![]() |
for each doc in dir, copy data to excel
Hello there,
I have a directory full of word docs. Each doc contains just name and address. Each doc was used to print an address label for a parcel. I need to get the name and address from each file, together with the date the file was created. This will provide a record in Excel of when each parcel was prepared for dispatch. I'm 99% sure this can be done with an Excel VBA routine, but I don't have the skill to write it myself. If anyone can help, Ill be most grateful indeed. Max |
for each doc in dir, copy data to excel
Max,
In psuedo-code, something like: 'Make a reference to the Word type library 'in VBEToolsreferences Dim Filename As String Dim FileCount As Long Dim WordApp As word.Application Dim WordDoc As word.document filename=dir(<path to the folder & "\*.doc") Set WordApp = New word.Application With Worksheets("data").Range("a1") Do While Filename < "" FileCount = FileCount + 1 set worddoc=wordapp.documents.open(<path to the folder & "\" & filename) .offset(filecount,0)=worddoc.<name data .offset(filecount,1)=worddoc.<address data .offset(filecount,2)=filedatetime(<path to the folder & "\" & filename) WordDoc.Close Loop End With WordApp.Quit You can record a macro in Word to see the syntax of getting the name and address data. NickHK "Max Bialystock" wrote in message ... Hello there, I have a directory full of word docs. Each doc contains just name and address. Each doc was used to print an address label for a parcel. I need to get the name and address from each file, together with the date the file was created. This will provide a record in Excel of when each parcel was prepared for dispatch. I'm 99% sure this can be done with an Excel VBA routine, but I don't have the skill to write it myself. If anyone can help, Ill be most grateful indeed. Max |
All times are GMT +1. The time now is 02:47 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com