日期:2008-10-19  浏览次数:20439 次

 

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