Thread: [Solved] Automate document properties
View Single Post
 
Old 07-31-2014, 01:03 PM
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

Update the code. This does not crash.

Code:
Sub SetProperties()
'
' Set key document properties
'
    Set docInfoTable = ThisDocument.Tables(1)
    Set docTitleCell = docInfoTable.Cell(Row:=2, Column:=2)
    Set docSubjectCell = docInfoTable.Cell(Row:=4, Column:=2)
    Set docAuthorCell = docInfoTable.Cell(Row:=9, Column:=2)
    Set docManagerCell = docInfoTable.Cell(Row:=10, Column:=2)
  
    ThisDocument.BuiltInDocumentProperties("title") = docTitleCell.Range.Text
    ThisDocument.BuiltInDocumentProperties("subject") = docSubjectCell.Range.Text
    ThisDocument.BuiltInDocumentProperties("author") = docAuthorCell.Range.Text
    ThisDocument.BuiltInDocumentProperties("manager") = docManagerCell.Range.Text
    ThisDocument.BuiltInDocumentProperties("category") = "Generic Template"
'
' Save the document
'
    ActiveDocument.Save
'
' This macro replaces FileSave on the CTRL+s keyboard shortcut
'
End Sub
But the value for all of the document properties is coming from docTitleCell.
Reply With Quote