doc name in field... without the ".doc"

  • Thread starter Thread starter Tony
  • Start date Start date
T

Tony

Is it possible to create a field that pulls the file name
from the document without the extension? i know you can
eliminate the file path. but you still end up
with "yourfilename.doc" I want to get it down to
just "yourfilename"

thanks for any help you can give...

Tony
 
Hi Tony,

The filename field doesn't support that, which is a shame. You could do it
with a macro, though. The following example shows how:

Sub NameIt()
Selection.Text = FileNameOnly(ActiveDocument.FullName)
End Sub

Function FileNameOnly(FullName As String)
Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")
FileNameOnly = fs.GetBaseName(FullName)
End Function

Run the NameIt macro and you'll get the filename inserted at that point.

Cheers
 
Thanks a bunch!!

-----Original Message-----
Hi Tony,

The filename field doesn't support that, which is a shame. You could do it
with a macro, though. The following example shows how:

Sub NameIt()
Selection.Text = FileNameOnly(ActiveDocument.FullName)
End Sub

Function FileNameOnly(FullName As String)
Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")
FileNameOnly = fs.GetBaseName(FullName)
End Function

Run the NameIt macro and you'll get the filename inserted at that point.

Cheers





---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.561 / Virus Database: 353 - Release Date: 13/01/2004


.
 
Back
Top