insert filename without extension .doc using fields?

G

Guest

Does anybody know how to insert a document file name and NOT include the file
name extesion eg ".doc". Surely there is a switch so the filename can be
shown without the extension?
 
S

Suzanne S. Barnhill

There is a "switch," but it's in Windows and applies to all files.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
G

Graham Mayor

The following macros will insert the document name or document path and name
without the extension - add to keystroke shortcuts or toolbar buttons
http://www.gmayor.com/installing_macro.htm

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

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


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

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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