Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.