Word

List document properties in table

Ease of Use

Easy

Version tested with

2000, 2002 

Submitted by:

MOS MASTER

Description:

All document properties are listed in a table at the start of the document. 

Discussion:

This gives a quick look at all the document properties of the active document. This way a author can check if all properties are filled in correct. 

Code:

instructions for use

			

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

How to use:

  1. Open your Word document.
  2. Press Alt + F11 to open VBE.
  3. Insert-Module. (Insert -> module)
  4. Paste the code there in the window at right. (F7)
  5. Close VBE (Alt + Q or press the X in the top right hand corner).
  6. Save the file.
  7. Make sure the sound file is in the same folder as the document! (Or change path in code)
 

Test the code:

  1. From Word, press Alt + F8 to open the macro dialog box.
  2. Select PropsToTable
  3. Click Run.
 

Sample File:

List document properties in Table.zip 9.02KB 

Approved by mdmackillop


This entry has been viewed 105 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express