Word 2007 - automatically populate document property using document contents

C

chuck.elsham

Hello,

I am a teacher & have to create a standard layout lesson plan for my
management's occasional perusal.

I'd like the box (cell in a Word 2007 table) which they have called
"Keywords" to automatically populate that document's tag (the metadata
that is visible in Explorer and is made available to Vista's search
via "tag:pythagoras")

Can anyone help? I assume I need to set that box to be a field, but
then how to write the file's metadata, and how to capture multiple
values into multiple tag values.

pythagoras; geometry ; proof

I'm in Word 2007 and about 5 years ago was a reasonable coder in VBA
for Excel 2003 if that's any use at all!

Cheers Rob
 
D

Doug Robbins - Word MVP

You would need to change the coordinates of the .Cell(1, 2) in following so
that it referred to the cell of the table into which the keywords are
entered. It assumes that the keywords are entered with a space between them
and the Replace function replaces that space with a semi colon and a space.

Dim keywords As String
Dim kwrange As Range
With ActiveDocument
Set kwrange = .Tables(1).Cell(1, 2).Range
kwrange.End = kwrange.End - 1
keywords = Replace(kwrange.Text, " ", "; ")
.BuiltInDocumentProperties(wdPropertyKeywords) = keywords
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
P

Peter Jamieson

Another way to do it might be to select the cell and use Insert
tab->Quick Parts->Document Property->Keywords. This inserts a "COntent
Control" (Word 2007 only). When you type in it, the Keywords builtin
document property is automatically updated, and vice versa. Of course
that means that you have to type your keywords exactly the way you want
them in the Property, but perhaps worth a try.

Peter Jamieson

http://tips.pjmsn.me.uk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top