Retrieve Document Properties in Word

M

Macro''''er

Hello,

I have several documents in one directory and would like to be able to run a
report on these documents to list the document properties such as Category,
Title, Last created? Can someone please help if there is a built in tool to
accomplish this?

Thank you and I look forward to your response.
 
G

Graham Mayor

There's no built-in tool, but it is simple enough to achieve with a macro
http://www.gmayor.com/installing_macro.htm :


Sub PropertiesReport()
Dim strFileName As String
Dim strPath As String
Dim oDoc As Document
Dim TargetDoc As Document
Dim proDoc As DocumentProperty
Dim fDialog As FileDialog
Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)
With fDialog
.title = "Select folder and click OK"
.AllowMultiSelect = False
.InitialView = msoFileDialogViewList
If .Show <> -1 Then
MsgBox "Cancelled By User", , _
"List Folder Contents"
Exit Sub
End If
strPath = fDialog.SelectedItems.Item(1)
If Right(strPath, 1) <> "\" _
Then strPath = strPath + "\"
End With
If Documents.Count > 0 Then
Documents.Close SaveChanges:=wdPromptToSaveChanges
End If
If Left(strPath, 1) = Chr(34) Then
strPath = Mid(strPath, 2, Len(strPath) - 2)
End If
strFileName = Dir$(strPath & "*.doc")
Set TargetDoc = Documents.Add
TargetDoc.Range.InsertAfter "Files in folder " & strPath & vbCr
While Len(strFileName) <> 0
Set oDoc = Documents.Open(strPath & strFileName)
With oDoc
TargetDoc.Range.InsertAfter .name
For Each proDoc _
In ActiveDocument.BuiltInDocumentProperties
With TargetDoc.Range
.InsertParagraphAfter
.InsertAfter proDoc.name & "= "
On Error Resume Next
.InsertAfter proDoc.Value
End With
Next
TargetDoc.Range.InsertParagraphAfter
.Close SaveChanges:=wdSaveChanges
End With
strFileName = Dir$()
Wend
For Each oPara In TargetDoc.Paragraphs
If InStr(1, oPara.Range, "=") = 0 Then
oPara.Range.Style = "Heading 2"
Else
oPara.Range.Font.Size = 10
With oPara.Range.ParagraphFormat
.LeftIndent = CentimetersToPoints(5)
.RightIndent = CentimetersToPoints(0)
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 0
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceSingle
.Alignment = wdAlignParagraphLeft
End With
End If
Next oPara
TargetDoc.Paragraphs(1).Range.Style = "Heading 1"
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
B

Bod

Hi!
We use the "Author" and "Manager" properties in files for the 2 approvers
(should really be "owner" and "approver").
In 2007, the dialogue box is replaced with a new form which doesn't have the
manager field or the hyperlink base (haven't compared anything else).
Is there a way to jump to the good old dialogue box without having to bother
with the new thing, as it is inadequate for my needs.
Better still, maybe I should be making my own dialogue box with the Owner
and Approver fields. It needs to be something hat is workable on other
people's machines too - not specific to mine.
Thanks in advance.
 

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

Top