Word Template that automaticallu creates the filename

P

Parisa

I’m a secretary trying to make my life easier. Our users fill in a word
template
and I’m supposed comply with our filenaming standard by renaming the file
using the data they entered into the fields.


Template Data
First Name Kim
Last Name Darter
Dept Human Resources
Company XYZ

Filename
Kim Darter Human Resources XYZ.doc




I’m looking for a word template that will automatically take the data from
the fields in the template (i.e. Kim, Darter, Human Resources, XYZ ) and
place them in the filename field when the user saves the template. So the
filename would be Kim Darter Human Resources XYZ.doc.

Thanks
 
D

Doug Robbins - Word MVP

What sort of fields are you talking about in the template. If they are
FormFields, then you can use the .Result attribute of each formfield to get
hold of the data that is entered the formfields and concatenate it into the
filename.

If your template has a userform into which the data is entered, then you
would do a similar thing with the .Text attribute of each of the textbox
controls.

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

Parisa

They are form fields.
How do you get the result into the filename when the form is saved. Please
explain using an example.

Thank You :)
 
D

Doug Robbins - Word MVP

Run a macro on exit from the last formfield that contains the code

Dim fname as String
With ActiveDocument
fname = .FormFields("[bookmarkname]").Result & " " &
..FormFields("[bookmarkname]").Result & " " & etc
.SaveAs fname
End With

Replace the square brackets and what's inside them with the respective names
of the bookmarks assigned to the formfields.
--
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
 

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