Autonaming doc on save using data from fill-in fields

C

Castor&Pollux

Hi All

I have read a couple of threads asking for similar stuff to what I'm looking
for but can't seem to get anything to work for me!

I have a word doc template that prompts the user upon opening to enter info
in fill-in fields. The fill-in fields are also bookmarked and ref fields
relating to the bookmarks appear in other parts of the document.

What I'd really like to do is when the user tries to close or save the
document it automatically uses data from two of the fill-in fields/bookmarks
as the document title.

Not sure if I'm going about things right in the set-up of my document to
start with so any advice is much appreciated.

Thanks :)
 
C

Cindy M.

Hi =?Utf-8?B?Q2FzdG9yJlBvbGx1eA==?=,

Show us the code you've tried, please. And which version of Word are you using?
I have read a couple of threads asking for similar stuff to what I'm looking
for but can't seem to get anything to work for me!

I have a word doc template that prompts the user upon opening to enter info
in fill-in fields. The fill-in fields are also bookmarked and ref fields
relating to the bookmarks appear in other parts of the document.

What I'd really like to do is when the user tries to close or save the
document it automatically uses data from two of the fill-in fields/bookmarks
as the document title.

Not sure if I'm going about things right in the set-up of my document to
start with so any advice is much appreciated.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
C

Castor&Pollux

Hi Cindy M

I am using Word 2003. I've tried playing with both of the following bits of
code which I pinched out of other threads in this forum.

With ActiveDocument
.SaveAs .Formfields("From").Result
End With

(I changed the "From" to the name of one of my ref fields).

AND

With ActiveDocument
.SaveAs "SW_COA_" & .Formfields("Text 2").Result & "_johnson.doc"
End With

(I got rid of the "SW_COA" & at the front, adjusted the "Text 2" to the name
of one of my ref fields and adjusted "_johnson.doc" to the remainder of my
proposed title).

The documents I am working on are templates for writing standardised
procedures. On closing, or saving the document I'd like the automatic
suggestion of "document title (SSAP) vX". Basically the "document title" and
the "X" would be the results entered in two fill-in fields (or ref fields if
need be).

I don't really have a great understanding of VBA as yet so the more straight
forward any direction, the better!

Let me know if you need any further info... hope it all makes sense!!!

Thanks

Castor&Pollux
 
C

Cindy M.

Hi P&C,
The documents I am working on are templates for writing standardised
procedures. On closing, or saving the document I'd like the automatic
suggestion of "document title (SSAP) vX". Basically the "document title" and
the "X" would be the results entered in two fill-in fields (or ref fields if
need be).
Right. Formfields are not the same as bookmarks, which is why you weren't able
to use the code snippets you found. A form field name is also a bookmark, but
the reverse does not apply.

The following shows you the approach I'd use. I may have not gotten the details
quite right (I don't know the bookmark names, for example), but you should be
able to adjust it to fit your needs.

Dim sDocTitle as String
Dim sX as String
Dim doc as Word.Document

Set doc = ActiveDocument
sDocTitle = doc.Bookmarks("Name").Range.Text
sX = doc.Bookmarks("otherName").Range.Text

doc.SaveAs sDocTitle & " (SSAP)v" & sX & *.doc"

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 

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