AutoText

K

Karen

I know there's AutoText for a file name (which adds the
file extension as well) Is there any way of adding
AutoText for the filename without the file extension?

Thank you
 
G

Graham Mayor

You can't do this with autotext, but you can do it easily with a macro. The
following examples insert the filename without the extension, with or
without the full path.

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

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

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

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Greg

Karen

Try changing your settings in Windows Explorer. View>Folder>Options and
check "Hide File Extensions for Known File Type"
 
C

Charles Kenyon

Except this can really mess up other things and result in files that are
named *.doc.dot, etc. It will fix what shows up in the document at the
expense of having a system that is more difficult to use.
 

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