1.word打开与关闭(VB.NET)

发表于:2007-07-01来源:作者:点击数: 标签:
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) @
 

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()

原文转自:http://www.ltesting.net