获取Word文件的运行实例 [英] Get Running Instances of Word File
本文介绍了获取Word文件的运行实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试读取Word文件路径,但是它在vb.net中返回了错误的路径,并且我正在使用Path.getfullpath
I'm trying to read word file path but it returns me the wrong path in vb.net and I'm using Path.getfullpath
For Each a In p
If Not pName.Equals("") And I <= p.Count Then
Console.WriteLine(a)
Console.WriteLine(p.Count)
pName = p(I).MainWindowTitle.ToString
File.WriteLine("Word Process Name : {0} is started on time {1}", pName, p(I).StartTime)
fullPath = Path.GetFullPath(pName)
File.WriteLine("Path Of the file is : {0}", fullPath(0))
End If
Next
推荐答案
您也可以 Microsoft.Office.Interop.Word
库
Dim wordApp As Microsoft.Office.Interop.Word.Application
wordApp = Marshal.GetActiveObject("Word.Application")
FileTxt = My.Computer.FileSystem.OpenTextFileWriter("E:\txt.txt", True)
For Each f In wordApp.Documents
pName = Path.GetFileName(f.FullName).ToString()
pPath = f.Path.ToString()
FileTxt.WriteLine("Word Process Name : {0} ", pName)
FileTxt.WriteLine("Path of File : {0} " , pPath)
Next
这篇关于获取Word文件的运行实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文