Group: microsoft.public.word.vba.general
From: "Graham Mayor"
Date: Sunday, February 10, 2008 5:11 AM
Subject: Re: MS Auto Insert in Headers

You cannot use parts of fields to derive information. What you can do is
insert the information with a macro.

Sub InsertfNameAndPath()
Dim pPathname As String
With ActiveDocument
If Len(.Path) = 0 Then
.Save
End If
If Right(.name, 1) = "x" Then
pPathname = Left$(.FullName, (Len(.FullName) - 5))
Else
pPathname = Left$(.FullName, (Len(.FullName) - 4))
End If
End With
Selection.TypeText pPathname
End Sub

or if you only want the filename and not the path, change each occurrence of
.FullName to .Name

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

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


ergeordie wrote:
> I am wondering if there is a way to use an auto insert in a header as
> a template and to have that auto inserted text not show the extension
> at the end? In other words, can I use some text that I have created
> to Auto Insert as a header in a Word document and when I inser the
> text, to not have the .doc at the end? Stefan Blom has already
> suggested turning off the 'Display File extension' selector within
> the OS. Is there any way to deal with the first issue? Can I use an
> Auto Insert as a template within a Header?
>
> Cheers,
>
> ergeordie


Safety Articles | Usenet Groups | Usenet News | Bluegrass