Thread: [Solved] Automate document properties
View Single Post
 
Old 08-04-2014, 05:54 AM
Ted C Ted C is offline Windows XP Office 2007
Novice
 
Join Date: Oct 2011
Posts: 18
Ted C is on a distinguished road
Default

This is the code.

Code:
Sub SetProperties()
'
' Set key document properties
'
Dim Rng As Range
With ActiveDocument
    '
    ' Category property
    .BuiltInDocumentProperties("category") = "Generic Template"
    '
    ' Title property
    Set Rng = .Tables(1).Cell(2, 2).Range
    Rng.End = Rng.End - 1
    .BuiltInDocumentProperties("title") = Rng.Text
    '
    ' Subject property
    Set Rng = .Tables(1).Cell(4, 2).Range
    Rng.End = Rng.End - 1
    .BuiltInDocumentProperties("subject") = Rng.Text
    '
    ' Author property
    Set Rng = .Tables(1).Cell(9, 2).Range
    Rng.End = Rng.End - 1
    .BuiltInDocumentProperties("author") = Rng.Text
    '
    ' Manager property
    Set Rng = .Tables(1).Cell(10, 2).Range
    Rng.End = Rng.End - 1
    .BuiltInDocumentProperties("manager") = Rng.Text
    '
    ' Save document - macro will be mapped to CTRL+S
    .Save
End With
 End Sub
Images of the table and document properties are attached.
Attached Images
File Type: png DocInfoTable.png (20.3 KB, 26 views)
File Type: png DocProperties.png (30.4 KB, 24 views)
Reply With Quote