如何从C#获取Word文档的文件名?

时间:2022-04-20 20:23:17

I'm working on a MS Word AddIn (VSTO). The idea is that I work on a Word document and I send it somewhere.

我正在研究MS Word AddIn(VSTO)。我的想法是我在Word文档上工作并将其发送到某个地方。

I have all the code I need except one thing: is there a way I can get the filename of the Word document I'm working on? (assuming that is already saved)

除了一件事,我有我需要的所有代码:有没有办法可以获得我正在处理的Word文档的文件名? (假设已经保存)

1 个解决方案

#1


this.FullName property in the code-behind .cs file should give you the entire path of the current doc.

代码隐藏.cs文件中的this.FullName属性应该为您提供当前文档的完整路径。

Here's the exact query in my QuickWatch window.

这是我的QuickWatch窗口中的确切查询。

((Microsoft.Office.Tools.Word.Document)(this)).FullName

#1


this.FullName property in the code-behind .cs file should give you the entire path of the current doc.

代码隐藏.cs文件中的this.FullName属性应该为您提供当前文档的完整路径。

Here's the exact query in my QuickWatch window.

这是我的QuickWatch窗口中的确切查询。

((Microsoft.Office.Tools.Word.Document)(this)).FullName