AutoText

  • Thread starter Thread starter Karen
  • Start date Start date
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
 
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

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
Karen

Try changing your settings in Windows Explorer. View>Folder>Options and
check "Hide File Extensions for Known File Type"
 
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.
--

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
Back
Top