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

I would like to automatically set certain document properties in a Word document when the user saves the file. I can send text to the properties, but I am having trouble retrieving the values I want to use from the document content.

The second page of the document is a table of document information, such as title, subject, and author. I want to use this table as the source for the document properties.

Here is my code.

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.Text
    ThisDocument.BuiltInDocumentProperties("subject") = docSubjectCell.Text
    ThisDocument.BuiltInDocumentProperties("author") = docAuthorCell.Text
    ThisDocument.BuiltInDocumentProperties("manager") = docManagerCell.Text
    ThisDocument.BuiltInDocumentProperties("category") = "Generic Template"
    
'
' Save the document
'
    ActiveDocument.Save
'
' This macro replaces FileSave on the CTRL+s keyboard shortcut
'
    
End Sub
I currently get "Run-time error '438': Object doesn't support this property or method" at the highlighted line.

If "Text" is not the property for the text contained in a table cell, what is?
Reply With Quote