How give a name to a document ?

M

MoiMeme

Hi

I know how to "save as" a document, but how can I first give the currently
document a name so teh user can determine when to save and have that name
appear in the save as dialog ?

TIA !!
 
G

Graham Mayor

When a new document is created from a template it is unnamed. Click the save
button and it will be default save the document in the Documents folder with
a name option taken from the first characters of the document. You can
replace that name in the save dialog with any name of your choice. Once the
document is saved, clicking save will save it with the same name.

If there is text in the Title field of the template properties then Word
will offer that as the name to save the document. Obviously you cannot save
more than one document of the same name in a folder so that would have
limited use.

If you wish to save documents with specific names then you are going to have
to use macros to do that. The macros would be saved in the relevant document
template. How best to achieve this rather depends on your intentions. For
example if you want a series of similar numbered documents, you could see
http://www.gmayor.com/save_numbered_versions.htm and
http://www.gmayor.com/automatic_numbering_documents.htm

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
M

MoiMeme

What I want is:

- user opens a blank document
- runs a vba code to populate the document with some formatted text in a
table ( functions Ok)
- give the document a name using 4 concatenated text strings

That way when the user saves the doc the name is already suggested and uses
a consistent way of naming

An idea ?
 
G

Graham Mayor

OK, but you will have to tell us where in the table the data is, whether
form fields are involved and what the strings are that you wish to use.
The Word version might be useful also.
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
M

MoiMeme

the four strings are in a forms fields
fields named string1 string2 and so on
i already use them to populate the document as string1.text and so on.
My only problem how can I affect a gieven string to some property of the
document so it "has a name". i do not find such a property i can use.

Word XP
 
G

Graham Mayor

If the fields are form fields named String1 to 4 then the following will
assemble them in that order interspersed by spaces (chr(32)) and will prompt
for a result if any of the fields is unfilled.

Dim s1 As String
Dim s2 As String
Dim s3 As String
Dim s4 As String
Dim fName As String
With ActiveDocument
s1 = .FormFields("String1").Result
If s1 = "" Then
MsgBox "You must complete field", vbCritical
.FormFields("String1").Select
Exit Sub
End If
s2 = .FormFields("String2").Result
If s2 = "" Then
MsgBox "You must complete field", vbCritical
.FormFields("String2").Select
Exit Sub
End If
s3 = .FormFields("String3").Result
If s3 = "" Then
MsgBox "You must complete field", vbCritical
.FormFields("String3").Select
Exit Sub
End If
s4 = .FormFields("String4").Result
If s4 = "" Then
MsgBox "You must complete field", vbCritical
.FormFields("String4").Select
Exit Sub
End If
End With
fName = s1 & Chr(32) & s2 & Chr(32) & s3 & Chr(32) & s4 & ".doc"
MsgBox fName
'ActiveDocument.SaveAs fName


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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
M

MoiMeme

Thanks !

Graham Mayor said:
If the fields are form fields named String1 to 4 then the following will
assemble them in that order interspersed by spaces (chr(32)) and will
prompt for a result if any of the fields is unfilled.

Dim s1 As String
Dim s2 As String
Dim s3 As String
Dim s4 As String
Dim fName As String
With ActiveDocument
s1 = .FormFields("String1").Result
If s1 = "" Then
MsgBox "You must complete field", vbCritical
.FormFields("String1").Select
Exit Sub
End If
s2 = .FormFields("String2").Result
If s2 = "" Then
MsgBox "You must complete field", vbCritical
.FormFields("String2").Select
Exit Sub
End If
s3 = .FormFields("String3").Result
If s3 = "" Then
MsgBox "You must complete field", vbCritical
.FormFields("String3").Select
Exit Sub
End If
s4 = .FormFields("String4").Result
If s4 = "" Then
MsgBox "You must complete field", vbCritical
.FormFields("String4").Select
Exit Sub
End If
End With
fName = s1 & Chr(32) & s2 & Chr(32) & s3 & Chr(32) & s4 & ".doc"
MsgBox fName
'ActiveDocument.SaveAs fName


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - 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