![word file extension word file extension](http://i.ytimg.com/vi/C3A1NVIyIkE/maxresdefault.jpg)
Select 'Quick Parts' in the 'Insert' tab, and click on 'Field.' ' AutoUpdate Macro which creates filename without extension and updates fieldsįname = Left(fname, Len(fname) - 5) 'removes the last five characters from the filename (.docm)įor Each aStory In ActiveDocument.StoryRanges 'updates all fields in the document when you open the fileĪfter you create this macro, simply go back to the document:
#Word file extension update
This macro will check what the filename is every time you open the file and will update all the fields in which you want the filename to be seen.
#Word file extension code
In order to have the document name automatically update in the fields, you need to add a little more code to your macro.
#Word file extension pdf
Maybe you could explain some more what you want to achieve with having the filename in the document header? Are you trying to use the filename in the document header to set some PDF property during conversion? Why not use the Document Title? Do you need the original filename in the PDF later - why? Also this Macro would run once and you would need to run it again when the filename changes. ".doc" - if you safe a ".docx" the "." would be preserved.
![word file extension word file extension](https://i.ytimg.com/vi/PLGSq0CqvO8/maxresdefault.jpg)
What it does is simply strip the last 4 characters of the "Filename string" e.g. Selection.InsertBefore Text:=Left(ActiveDocument.Name, Len(ActiveDocument.Name) - 4)
![word file extension word file extension](https://images.wondershare.com/recoverit/article/2019/06/fix-corrupted-word-files-23.jpg)
So, either you change that setting or you need some code.Ī very simple Macro would be the following: Sub InsertCurrentFileName() To show or not to show (Shakespearean style) the extension is purely up to the Windows Explorer setting to show or hide known file extensions. Insert > QuickParts > Field > FileName is the way to go, but as you see from the screenshot below, you do not have the option to turn the file extension on or off.