.docx in FileName

C

CJ

In Word 2007, is there a way to remove the file extension from the
result of the FileName field?
 
G

Graham Mayor

No - you cannot insert parts of fields. You can however insert the relevant
part of the filename with a macro e.g. the following will insert the
filename and path (w/o extension) at the cursor. The second macro will
insert just the filename (w/o extension)

Sub InsertfNameAndPath()
With ActiveDocument
If Len(.Path) = 0 Then .Save
Selection.TypeText Left(.FullName, _
InStrRev(.FullName, ".") - 1)
End With
End Sub

Sub InsertFnameOnly()
With ActiveDocument
If Len(.Path) = 0 Then .Save
Selection.TypeText Left(.name, _
InStrRev(.name, ".") - 1)
End With
End Sub

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

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