插入文档的部分文件路径


0

我想将文档的文件路径添加到我的所有文档的底部。我知道我可以编辑默认模板并使用fields变量添加它。

但我想知道是否可以只显示部分文件路径。例如,只有下面的粗体部分。

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

我已经看过了,并且无法通过内置函数找到任何方法。我创建宏或自定义单词加载项的下一个想法,但我制作它们的经验是有限的。

Answers:


0

管理用自定义单词加载项解决它我自己。它不会像我想要的那样将它添加到模板中,但是在按下按钮时会将其添加到模板中。这是我用来的代码

        //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;
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.