开发者

c# word-2007 add-in: get the path and filename of current opened wordfile?

I am coding da latex-addin with visual studio 2008 for word 2007.

My question: how do I get the the current path and filename of the opened file? example: If i open the C:\edu\test.docx with word 2007, my add-in have to get me "C:\edu\test.docx" shown in a MessageBox.

HOW does it work?? iam going mad.

I tryed met开发者_运维百科hodes of Microsoft.Office.Interop.Word or Microsoft.Office.Tools.Word, but i think these only get informations from new Objects, so these ist what iam looking for.

Does this path+filename exist in the System Properties? In google I didnt find any useful results.

thanks a lot

robert


Though my answer is late enough to help you anymore, yet I shall put it in here to help someone else who comes along. In word 2007, within the add in you can call Name , FullName and Path properties of the active document as follows

        // Get the Active document 
        var doc = Globals.ThisAddIn.Application.ActiveDocument;

        MessageBox.Show("Document Name : " + doc.Name);
        MessageBox.Show("Document Full Name : " + doc.FullName);
        MessageBox.Show("Document Path : " + doc.Path);

if the document is saved, all three shall return documentName , documentName with path , path of documentonly, respectively. if the document is not saved, it shall show Document1, Document1, (empty path) respectively.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜