Link to home
Start Free TrialLog in
Avatar of mtthompsons
mtthompsons

asked on

Extract all word files properties script

Hi all,
Extract all word files properties script.
I have few 1000's of files and want to extract all details possible to an excel, so i can compare and take some actions.
Like Owner name/system name etc etc
Can anyone help me please
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Here is a Word VBA macro to get you started.
It creates a new workbook. It then cycles through a folder looking for Word documents.  From each document it saves four built-in properties and the full document name to the first worksheet.
Note that it uses early binding so needs a reference to the Microsoft Excel Object library
Sub CollectDocData()
    Dim strFolder As String
    Dim strFile As String
    Dim Doc As Document
     Dim xlApp As Excel.Application
    Dim xlWbk As Excel.Workbook
    Dim xlWks As Excel.Worksheet
    Dim r As Integer
    Dim prop As DocumentProperty
    'Initialize Excel'
    Set xlApp = CreateObject("Excel.Application")
    xlApp.Visible = True
    Set xlWbk = xlApp.Workbooks.Add
    Set xlWks = xlWbk.Worksheets(1)
   xlWks.Cells(1, 1).Value = "Title"
   xlWks.Cells(1, 2).Value = "Subject"
   xlWks.Cells(1, 3).Value = "Author"
   xlWks.Cells(1, 4).Value = "Creation Date"
   xlWks.Cells(1, 5).Value = "Full Name"
    strFolder = "C:\MyWordDocs"
    strFile = Dir(strFolder & "\" & "*.docx")
    r = 2
    Do Until Len(strFile) = 0
        Set Doc = Documents.Open(strFolder & "\" & strFile)
        xlWks.Cells(r, 1).Value = Doc.BuiltInDocumentProperties("Title")
        xlWks.Cells(r, 2).Value = Doc.BuiltInDocumentProperties("Subject")
        xlWks.Cells(r, 3).Value = Doc.BuiltInDocumentProperties("Author")
        xlWks.Cells(r, 4).Value = Doc.BuiltInDocumentProperties("Creation Date")
        xlWks.Cells(r, 4).NumberFormat = "dd/mm/yyyy"
        xlWks.Cells(r, 5).Value = Doc.FullName
        Doc.Close wdDoNotSaveChanges
        r = r + 1
        strFile = Dir()
    Loop
End Sub

Open in new window

Avatar of mtthompsons
mtthompsons

ASKER

Perfect
Can i get these headers also please
Computer Name
Revision No
Last Saved by
Company
Also many files get rejected as it says cannot open or it says corrupted.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.