A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Page Layout
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

.docx in FileName



 
 
Thread Tools Display Modes
  #1  
Old December 18th, 2009, 05:20 PM posted to microsoft.public.word.pagelayout
CJ[_2_]
external usenet poster
 
Posts: 35
Default .docx in FileName

In Word 2007, is there a way to remove the file extension from the
result of the FileName field?
  #2  
Old December 19th, 2009, 01:33 PM posted to microsoft.public.word.pagelayout
Graham Mayor
external usenet poster
 
Posts: 18,297
Default .docx in FileName

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

My web site www.gmayor.com
Word MVP web site http://word.mvps.org




"CJ" wrote in message
...
In Word 2007, is there a way to remove the file extension from the
result of the FileName field?



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:16 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.