Removing the file extension from an inserted field/filename

  • Thread starter Thread starter Rick
  • Start date Start date
R

Rick

Is there a simple way to remove the file extension from an inserted field/filename (without changing folder preferences in Windows to not display extensions for known file types)?

If not simple, does anyone already have the required VBA code to do this?

Regards
 
Whether or not the extension is displayed it is always part of the filename.
The extension is the initial method by which files are identified by
Windows. Why would you want to remove it from a field?

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

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
I use the filename within a printed document and do not want to display the
fact that it is a word document. The .doc would thus display.

Any suggestions on how this can be acheived?

Regards
 
In that case use a macro to insert the filename without the extension -

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

will insert the path and filename
change the line fname=
to
fname = Selection.Document.Name
if you want to omit the path


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

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
Back
Top