Dynamically assigning Doc properties

F

Fer

Hi,
I have a Word template with a series of text fields in it. Two of the
fields are:
- Title
- Subject
I would like to generate documents, that automatically get assigned the
contents of those two fields onto the title and subject of the document
property.
Somebody can hint me how to do this? I tried recording a macro and
checking the code, but the macro does not display anything when I
manually write onto the the Properties box.
Regards.


Fer
 
J

Jonathan West

Hi Fer

By "text fields" do you mean Formfields?

If so, then create the following two macros

Sub SetTitle
ActiveDocument.BuiltInProperties("Title") = _
ActiveDocument.FormFields("Title").Result
End Sub

Sub SetSubject
ActiveDocument.BuiltInProperties("Subject") = _
ActiveDocument.FormFields("Subject").Result
End Sub

Set the Calculate On Exit property for each formfield to the appropriate
macro.

--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
F

Fer

Thanks for your reaction, Johnatan.
Yes, I meant text within in a form. I will try the macros.
Best regards.

Fer
 
Top