Setting The Title When You Save A Word Document

S

Stanza

Hi,

I am trying to automatically populate the title of a document when I save
the document. The tile is to be populated with a value for a particular merge
field.

I am relatively new to macro vba programming so I do not have much of an
idea of how to do this,

I know you can use the code:
activedocument.BuiltInDocumentProperties.item("Title").value = “Valueâ€

How do you do this for a mergefield?

Cheers,

Stanley
 
D

Doug Robbins - Word MVP

See the “Individual Merge Letters†item on fellow MVP Graham Mayor’s website
at:

http://www.gmayor.com/individual_merge_letters.htm

If you are using Word XP or later, the “Add-in to Merge Letters to Separate
Files†that Graham and I have collaborated on and that can be downloaded
from that site will allow you to create each letter as a separate file with
a filename taken from a field in the data source with a minimum of fuss.


--
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
 
S

Stanza

Thanks for the info Doug but that doesn’t show what I’m after. I want to
programmatically set the title of the document in a function so that this can
be called by another routine from an external application.

So the vba code for this macro should look something like:

Sub SaveDocument()

activedocument.BuiltInDocumentProperties.item("Title").value = ‘MergeField’

End Sub

The external application will then calle the name of this function
(SaveDocument) after the merge operation.

Any ideas? I’m sure this is pretty simple. I just don’t know enough of the
syntax for macro programming…
 
G

Graham Mayor

The page to which Doug referred you on my web site demonstrates a method to
name the document from the merge, and also provides an add-in that will
create merged documents already named from the merge data.

The content of the mergefield is not present to be added to the document
properties until the merge is run and during the merge the field is
converted to text so afterwards is not present again. Without knowing
anything about your process, it is impossible to suggest a practical way
forwards.

It may however be possible to extract a particular text from a document
after the merge provided it is always located in the same place, to be
either added to the document's properties.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
S

Stanza

Hi,

Thanks for pointing me into the right direction. I managed to get this
working by manually recording the macro to select the merge field text and
then use those co-ordinates to program around it.

I have noticed that you cannot access the merge field values by referencing
the merge field name by the use of a macro.

I am quite surprised as this is only process that will achieve what I want
to do and I find this quite primitive, especially coming from the world’s
largest software vendor..
 

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