Custom Document Properties (1 Viewer)

tecknologika

New member
Local time
Today, 03:11
Joined
Nov 20, 2016
Messages
3
I'm developing a database to create a hyperlinked index of files in a folder. I'm trying to get document properties for all files in a folder. Properties like FileName, Author, and Tags. Using VBA, how can I grab document property information from each file and store it in a table. The documents are Word documents.
Thanks
 

Orthodox Dave

Home Developer
Local time
Today, 08:11
Joined
Apr 13, 2017
Messages
218
Hi,

I've just found this online, modified and tested it and it works:-
Code:
Sub ExtractWordProperties(strInFile As String)
Dim objWord As Object, objDocProps As Object
Dim i As Integer
    On Error Resume Next
    Set objWord = CreateObject("Word.Application")

    With objWord
        .Documents.Open Filename:=strInFile
        Set objDocProps = objWord.ActiveDocument.BuiltinDocumentProperties

        For i = 1 To objDocProps.Count
         Debug.Print objDocProps(i).NAME, objDocProps(i)
        Next i

    End With

    objWord.Application.Quit savechanges:=False
    Set objWord = Nothing
End Sub

for "strInFile" you need the full path of the file.

Not sure how advanced you are. The above will extract the properties but I haven't said how you put these into a table. You need to create a table with fields such as File, Property Type and Property. Then use an Insert query sql to add the properties to your table. Are you happy with that or do you need more help?
 

Users who are viewing this thread

Top Bottom