Option Explicit
Sub PropsToTable()
Dim oRange As Word.Range
Dim oProp As DocumentProperty
Dim sTmp As String
'\\ value for table header
sTmp = "Property Name" & vbTab & "Property Value"
'\\ To continue if a document property has no value set
On Error Resume Next
'\\ Loop document properties and build tab delimeted string
For Each oProp In ActiveDocument.BuiltInDocumentProperties
sTmp = sTmp & vbTab & oProp.Name & vbTab & oProp.Value
Next
'\\ Set reference to start of document (range)
Set oRange = ActiveDocument.Range(0, 0)
'\\ Insert the string and covert it to a table
With oRange
.InsertAfter Text:=sTmp
.ConvertToTable Separator:=wdSeparateByTabs, _
NumColumns:=2, _
AutoFit:=True
End With
'Clean up
Set oRange = Nothing
End Sub
|