Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Populate file properties from text fields in document
I am trying to get the Subject and Title from the file properties of a
document to be set automatically from specified text fields in the body of the document. I can quite easily go the other way by typing text into the title and subject fields in the properties dialog box, and inserting relevant fields into the document, but that's not what I want. Is there a way to do it using macros, or can I insert a field so that when a user edits the field, it will automatically update the file properties. Is this even possible? I consider myself an 'advanced user' of Word, but with some limited experience in coding, just so you'll know where to pitch any answer to me. Thanks. |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Populate file properties from text fields in document
Set the following macro to run on exit from text formfields Text1 and
Text2 Sub OnExitTF() Dim oFF As FormFields Set oFF = ActiveDocument.FormFields Dim pStr As String If Selection.FormFields.Count = 1 Then pStr = Selection.FormFields(1).Name ElseIf Selection.FormFields.Count = 0 And Selection.Bookmarks.Count 0 Then pStr = Selection.Bookmarks(Selection.Bookmarks.Count).Nam e End If Select Case pStr Case "Text1" ActiveDocument.BuiltInDocumentProperties("Title"). Value = oFF("Text1").Result Case "Text2" ActiveDocument.BuiltInDocumentProperties("Subject" ).Value = oFF("Text2").Result End Select End Sub On Apr 24, 6:44 am, Embobz wrote: I am trying to get the Subject and Title from the file properties of a document to be set automatically from specified text fields in the body of the document. I can quite easily go the other way by typing text into the title and subject fields in the properties dialog box, and inserting relevant fields into the document, but that's not what I want. Is there a way to do it using macros, or can I insert a field so that when a user edits the field, it will automatically update the file properties. Is this even possible? I consider myself an 'advanced user' of Word, but with some limited experience in coding, just so you'll know where to pitch any answer to me. Thanks. |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Populate file properties from text fields in document
If you have Word 2007 then all you have to do is insert bound Document
Property fields in your document. They are found on the Insert tab under Quick Parts. Very cool, I might add. You can update the document properties or use the bound doc property fields to update the properties. You can also add multiple bound doc property fields if you need the data repeated in your document. All of the fields and the properties update automatically - all you have to do is insert the field. :-) Please post all follow-up questions to the newsgroup. Requests for assistance by email can not be acknowledged. ~~~~~~~~~~~~~~~ Beth Melton Microsoft Office MVP Co-author of Word 2007 Inside Out: http://www.microsoft.com/MSPress/boo...x#AboutTheBook Word FAQ: http://mvps.org/word TechTrax eZine: http://mousetrax.com/techtrax/ MVP FAQ site: http://mvps.org/ "Embobz" wrote in message ups.com... I am trying to get the Subject and Title from the file properties of a document to be set automatically from specified text fields in the body of the document. I can quite easily go the other way by typing text into the title and subject fields in the properties dialog box, and inserting relevant fields into the document, but that's not what I want. Is there a way to do it using macros, or can I insert a field so that when a user edits the field, it will automatically update the file properties. Is this even possible? I consider myself an 'advanced user' of Word, but with some limited experience in coding, just so you'll know where to pitch any answer to me. Thanks. |
#4
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Populate file properties from text fields in document
Greg,
Thanks for the code. It does what I want it to do, but I'm having problems getting the macro to run 'on exit'. By the way, it's Word 2003 - I didn't mention that. Either I'm being a bit dim, or I didn't explain properly exactly what I was trying to do. I need to have some existing text that will tell the user that they need to 'type subject here' etc. but then whatever they type is then put into the subject/ title field of the properties. The problem I'm having is that as soon as you type into the text formfield, it is replaced by the normal text, the text formfield no longer exists, and so the macro cannot run 'on exit' from a non-existent field. More help please! Emma |
#5
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Populate file properties from text fields in document
On 24 Apr, 15:44, "Beth Melton" wrote:
If you have Word 2007 then all you have to do is insert bound Document Property fields in your document. They are found on the Insert tab under Quick Parts. Very cool, I might add. You can update the document properties or use the bound doc property fields to update the properties. You can also add multiple bound doc property fields if you need the data repeated in your document. All of the fields and the properties update automatically - all you have to do is insert the field. :-) Beth, That does sound very cool. I wish that it were Word 2007 - it sounds like life would be much simpler! Unfortunately it is Word 2003. Emma |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Fields to populate a document | Microsoft Word Help | |||
Hidden fields populate main doc, but are not entirely visible | Microsoft Word Help | |||
Populate Merge Fields via VB.NET | Mailmerge | |||
Creating a form to have all fields populate same criteria | New Users | |||
Why won't Word allow me to add or delete custom fields under file/properties | Microsoft Word Help |