Add a filename field without .doc extension in document header

Your feeling is quite right.

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. alt text 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. So, either you change that setting or you need some code.

A very simple Macro would be the following:

Sub InsertCurrentFileName()
    Selection.InsertBefore Text:=Left(ActiveDocument.Name, Len(ActiveDocument.Name) - 4)
End Sub

What it does is simply strip the last 4 characters of the "Filename string" e.g. ".doc" - if you safe a ".docx" the "." would be preserved. Also this Macro would run once and you would need to run it again when the filename changes.

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?

Two more pages to help you with your problem (both relying on Macros...):

  • insert filename without extension .doc using fields?
  • Inserting a File Name without an Extension

add [Title] Instead of filename and maybe add some of the Other Document Properties Listed