Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Embobz Embobz is offline
external usenet poster
 
Posts: 4
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Greg Maxey Greg Maxey is offline
external usenet poster
 
Posts: 264
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Beth Melton Beth Melton is offline
external usenet poster
 
Posts: 1,380
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Embobz Embobz is offline
external usenet poster
 
Posts: 4
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Embobz Embobz is offline
external usenet poster
 
Posts: 4
Default 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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Fields to populate a document Yacbo Microsoft Word Help 2 November 14th 06 02:34 PM
Hidden fields populate main doc, but are not entirely visible Jenna B Microsoft Word Help 1 February 20th 06 11:56 PM
Populate Merge Fields via VB.NET ben Mailmerge 5 June 21st 05 05:43 PM
Creating a form to have all fields populate same criteria HT New Users 3 April 26th 05 06:08 PM
Why won't Word allow me to add or delete custom fields under file/properties hike Microsoft Word Help 4 February 4th 05 08:24 PM


All times are GMT +1. The time now is 07:51 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"