Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to add the file path of a document to the bottom of all my documents. I know that I can edit the default template and add it using fields variable.

But I want to know if it's possible to only show part of the file path instead. E.g. Only the bold part below.

C:\Users\Mark\Documents\Dropbox\ Uni Work\Semester 4\Software Project Practices and Management\Assignments\Assignment 3\Assignment 3 Final.docx

I've looked and can't find any way to do this with an inbuilt function. My next ideas where creating either a macro or custom word add-in, but my experience with making them is limited.

share|improve this question
up vote 0 down vote accepted

Managed to solve it my self with a custom word add-in. It doesn't add it to the template like I wanted but adds it in when the button is pressed. Here's the code I used for it

        //Declare Variables
        Document activeDoc = Globals.ThisAddIn.Application.ActiveDocument;
        String fullFileLocation;
        String shortenedFileLocation;

        //Get the current cursor location
        Range rng = Globals.ThisAddIn.Application.Selection.Range;

        //Get current file location
        fullFileLocation = activeDoc.FullName;
        //Set Remove starting location      
        shortenedFileLocation = fullFileLocation.Replace("C:\\Users\\Mark\\Documents\\Dropbox\\", "");

        //Insert the shortened file location
        rng.Text = shortenedFileLocation;
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .