![]() |
#1
|
|||
|
|||
![]()
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 If "Text" is not the property for the text contained in a table cell, what is? |
Tags |
properties |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
KJJ | Word VBA | 14 | 11-10-2016 08:18 PM |
![]() |
thedr9wningman | Word VBA | 3 | 01-20-2014 05:56 PM |
Key shortcut to access document properties | eroock | Word | 0 | 12-11-2012 10:54 AM |
![]() |
NicBodkin | Word | 8 | 05-05-2011 09:09 AM |
document properties issues | charris1980 | Word | 0 | 04-29-2009 12:49 PM |