Imports Word
'打开
Dim mWordapp As Word.Application 'word 应用程序
Dim mobjDoc As Word.Document 'word 文档
Dim fullFileName As String '文件路径
mWordapp = CreateObject("Word.Application")
mobjDoc = mWordapp.Documents.Add(fullFileName)
'关闭
Dim missing As Object = System.Reflection.Missing.Value
mWordapp.Application.Quit()
If Not mobjDoc Is Nothing Then
'垃圾回收
System.Runtime.InteropServices.Marshal.ReleaseComObject(mobjDoc)
mobjDoc = Nothing
End If
If Not mWordapp Is Nothing Then
System.Runtime.InteropServices.Marshal.ReleaseComObject(mWordapp)
mWordapp = Nothing
End If
'真正释放word进程
GC.Collect()
End Sub
这是我从网上找到的资料,但命名空间错了,然合我又找word的命名空间"Imports Microsoft.Office.Interop.Word" 但这个好像也是错的,麻烦有相关资料或书的朋友帮我看一下word的命名空间!