Footer field

S

skylark_za

I am wanting to show the name of the document in the footer but without the
document extension (.doc) Please could somebody explain how I would do this.

Thanks
 
S

Stefan Blom

The Word FILENAME field uses the settings of Windows Explorer; and you
cannot work around that. Maybe you can get the file name minus the
extension with a macro, but you'll have to ask in a VBA newsgroup to
find out.
 
G

Graham Mayor

skylark_za said:
I am wanting to show the name of the document in the footer but
without the document extension (.doc) Please could somebody explain
how I would do this.

Thanks

You cannot do it with a field, but it is easy enough to achieve with a
macro. The first macro will insert the name and path, the second just the
name.


Sub InsertfNameAndPath()
Dim fname, fname2, pathname As String
If ActiveDocument.Saved = False Then ActiveDocument.Save
fname = Selection.Document.FullName
fname2 = Selection.Document.Name
pathname = Left(fname, (Len(fname) - 4))
Selection.TypeText pathname
End Sub

Sub InsertFnameOnly()
Dim fname, fname2 As String
If ActiveDocument.Saved = False Then ActiveDocument.Save
fname2 = Selection.Document.Name
fname = Left(fname2, (Len(fname2) - 4))
Selection.TypeText fname
End Sub

See http://www.gmayor.com/installing_macro.htm


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


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

skylark_za

Graham

Your macros do what you say however how do I get this to update should I now
save the document as another name? The footer shows the name of the saved
document and the name of this document can change. (I hope this all makes
sense?)

Thanks
 
G

Graham Mayor

Obviously it doesn't. As indicated you cannot achieve this with a field. You
would need to replace the information. However, there should be no reason to
change the name of the document. Save the document as a template (along with
the macros) and create a new document each time.

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